i made a stun script inside a tool, and its not detecting when i press P, whats wrong with my code? all the stun thing i working, i tested it before without using that P bind.
local looping = 0 local tool = script.Parent local plrs = game:GetService("Players") local plr = plrs.LocalPlayer local char = plr.Character game:GetService("UserInputService").InputBegan:Connect(function(key, processed) if processed then return end if key.UserInputType == Enum.KeyCode.P then if looping == 0 then looping = 1 elseif looping == 1 then looping = 0 end end ----------------------------------- while looping == 1 do print("Stun Thing bro") for _, v in pairs(game.Players:GetChildren()) do wait(.1) if v.Character ~= char then if (v.Character.Head.Position - char.Head.Position).magnitude <=15 then v.Character.Humanoid.WalkSpeed = 1 v.Character.Humanoid.JumpPower = 0 elseif (v.Character.Head.Position - char.Head.Position).magnitude >15 then v.Character.Humanoid.WalkSpeed = 16 v.Character.Humanoid.JumpPower = 50 end end end end end)
The error is ur doing if key.UserInputType
Thats not how you compare keycodes, do this instead if key.KeyCode