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)
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)