Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How i can make a Proximity Stun Skill?

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

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)	

6 comments

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

0

if you dont want it as tool then just use

0

and put in starterplayerscripts

0

Bravo "Mouse.KeyDown"

0

TTChaos shut ur furry 487 visits up

This discussion is preserved as it was. New answers, comments, and votes are closed.