guys, im making a stun skill what if i press P if get active and keep looking for ppl what get close to me for stun them, and if i press P again it stop look for ppl, but its not working, can you guys see my script pls?
game.ReplicatedStorage.StunThingP.OnServerEvent:Connect(function(player) local UIS = game:GetService("UserInputService") local looping = false UIS.InputBegan:Connect(function(inp) if inp.KeyCode == Enum.KeyCode.P then if looping == false then looping = true while looping == true do for _, v in pairs(game.Players:GetPlayers()) do print("stun hmmmm!") if v.Character ~= player.Character then if (v.Character.Head.Position - player.Character.Head.Position).magnitude <=15 then v.Character.Humanoid.WalkSpeed = 1 v.Character.Humanoid.JumpPower = 0 elseif (v.Character.Head.Position - player.Character.Head.Position).magnitude >15 then v.Character.Humanoid.WalkSpeed = 16 v.Character.Humanoid.JumpPower = 50 end end end end if inp.KeyCode == Enum.KeyCode.P then looping = false end end end end) end)