---Variables
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
Fireclient:
game.ReplicatedStorage.Client.OnClientEvent:Connect(function(Arg)
if Arg == "Stunned" then
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
repeat wait()
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
until not Player.Status:FindFirstChild("Stunned")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
RenderStepped:
game:GetService("RunService").RenderStepped:Connect(function()
if Player.Status:FindFirstChild("Stunned") then
Humanoid.WalkSpeed = 0
else
Humanoid.WalkSpeed = 16
end
end)
I know the renderstepped and fireclient will have some bugs(like overlapping walkspeed etc), but for the sake of comparison let’s pretend I fixed those. Which is better for the stun system? or are they both basically the same? I’m looping them just in case exploiters try to change their walkspeed, so that it can somewhat prevent it.
There’d be multiple effects for the stuff I’m doing such as slowness, can’t jump and react to hits(getting slowed when punched), etc so I just chose to alternate the walkspeed instead for easier modification I guess, and I never touched Platformstand cause I’ve never seen games with somewhat realistic combat use that and it clips through the platform.
You can make a stun folder in StarterCharacter and everytime you want someone to be stunned make a number value called “Stun” , make the value how long you want them to be stun, and then add the Stun value to the Stun Folder.
local Character = script.Parent
local Stuns = Character.StunFolder
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
Stuns.ChildAdded:Connect(function(Chi) -- Chi is the object
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
wait(Chi.Value)
Chi:Destroy()
repeat game:GetService("RunService").Heartbeat:Wait() until not Stuns:FindFirstChild("Stun")
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end)
The script above would be placed in a local script in starterCharacter