Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to make a Stun Skill with P to activate and keep looping it unless i press P again?

Asked by 2 days ago
Edited 2 days ago

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)
0
im using a LocalScript to detect when i press P and activating a RemoteEvent, should i use this or i can make this skill in just a single script? i want make it "giveable", for i give it just for me. ArielEtzao 2 — 2d
0
What is the problem? Is it not starting at all? Is it not stopping? Is it not looping? I can't exactly help if I don't know the specifics of the problem. A_thruZ 29 — 2d
0
its not starting when i tried to made that loop function, then.. isnt looping too. ArielEtzao 2 — 2d

Answer this question