Hard to say for sure, but you have a few things that don't look right to me. First, you define Range at the top, but then proceed to check its value each time onKeyPress is called, even though you never redefine it. Thus, I recommend simply making the if statement say
if script.Parent.InRange.Value == true then
Second, saying
local Sword = game.workspace.Sword.Name == "Sword"
will always return 'true' unless Sword doesn't exist in the workspace, in which case your code will error. |