Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How i can make a Proximity Stun Skill?

Asked by 3 years ago
Edited 3 years ago

i want make a skill what i can press a key (P) and it activate, and with magnitude make it stun ppl what get close to me, i know how to make the stun thing and magnitude thing, but idk how to make it a Skill what i can just have it and when i press P it activate, if i press P again it deactivate, some help? its my script what i've made, is just for make a example of what i have done. (and no, i dont want make it in a tool, i sent this script just for a example, i want make it like a skill what i can just press P and it activate, without Tools and nothing else).

local UIS = game:GetService("UserInputService")
local p = Enum.KeyCode.P
local players = game:GetService("Players")
local stun = false          
local tool = script.Parent

local function onEquip()
    local char = tool.Parent
    for _, v in pairs(players:GetChildren()) do
        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
                end
        end
    end
end
UIS:IsKeyDown(p):Connect(onEquip)

1 answer

Log in to vote
-1
Answered by 3 years ago

Because of FE, some has to be done on the server. I made it so it disables after a few seconds, but you could change it if you wanted.

Client:

local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()

local function onEquip()
    local char = tool.Parent
    mouse.KeyDown:Connect(function(k)
        if k == "p" then
            game.ReplicatedStorage.RemoteEvent:FireServer()
        end
    end)
end
tool.Equipped:Connect(onEquip)

Server:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    for _, v in pairs(game.Players:GetChildren()) do
        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
                wait(3)
                v.Character.Humanoid.WalkSpeed = 16
                v.Character.Humanoid.JumpPower = 50
            end
        end
    end
end)    
0
i put the first script in a Local script inside the Tool, right? and the second one in a script inside the ServerScriptService?, if yes, ok, but i dont want make it in a tool, i sent that script just for a example Ariirael 15 — 3y
0
if you dont want it as tool then just use NotMiskie 78 — 3y
0
and put in starterplayerscripts NotMiskie 78 — 3y
View all comments (2 more)
0
Bravo "Mouse.KeyDown" User#30567 0 — 3y
0
TTChaos shut ur furry 487 visits up NotMiskie 78 — 3y
Ad

Answer this question