I'm making a sword and the local script doesn't run at all. I tested it with prints on the first line, none showed up. I put a clearly horrible line of code, no error. Why won't it run?
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
local rs = game:GetService("ReplicatedStorage")
local player = script.Parent.Parent.Parent
local name = player.Name
local o = name.."swordout"
local u = name.."swordup"
local s = name.."slashsound"
local f = rs.PlayerStuff
local so = f:FindFirstChild(o)
local su = f:FindFirstChild(u)
local sou = f:FindFirstChild(s)
so:FireServer()
sou:FireServer()
wait(.2)
su:FireServer()
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Q)
debounce = false
target = "Humanoid"
script.Parent.Handle.Touched:Connect(function (hit)
if debounce == false and hit.Parent:FindFirstChild(target) then
local Players = game:GetService("Players")
local damage = script.Parent.Damage.Value
local nam = hit.Parent.Name
if Players:FindFirstChild(nam) then
local hitplayer = Players:FindFirstChild(nam)
local hpc = hitplayer.Character
local hum = hpc.Humanoid
hum.Health = hum.Health -damage
local debounce = true
wait(1)
local debounce = false
end
end
end)
This local script works fine w/o EM though, it only breaks with EM. I'll move the damage part to a remote event later.

2 comments
Where is the LocalScript
Directly inside the tool, which is inside the backpack.