I’ve been wondering for days on how I could make a good stun system but fail to think of a good way to make one. The one i’m currently using now involves a Runservice a an IF function that detects if a instance with the name block is inside the character and then proceeds to set the humanoid walkspeed to 2 and the jumppower to 0 and if there isn’t instance with the name block then the humanoid walkspeed and jumpower is 12 and 45; heres an example of the script:
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
local HumanoidRootPart = Character.HumanoidRootPart
game:GetService("RunService").RenderStepped:Connect(function()
if Character:FindFirstChild("Stunned") then
Humanoid.Walkspeed = 2
Humanoid.JumpPower = 0
else
Humanoid.Walkspeed = 12
Humanoid.JumpPower = 45
end)
Now you may be wondering what’s wrong with this ? Nothing but there are bound to be bugs happening from time to time with this type of stun system. The most you could do is create a IF function for something that shouldn’t trigger the else like;
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
local HumanoidRootPart = Character.HumanoidRootPart
game:GetService("RunService").RenderStepped:Connect(function()
if Character:FindFirstChild("Stunned") then
Humanoid.Walkspeed = 2
Humanoid.JumpPower = 0
else
if Character:FindFirstChild("Sprint") then
Character.Humanoid.WalkSpeed = 21
Character.Humanoid.JumpPower = 42.5
return
elseif Character:FindFirstChild("Block") then
Character.Humanoid.WalkSpeed = 8
Character.Humanoid.JumpPower = 42.5
return
elseif Character:FindFirstChild("Dash") then
return
end
Humanoid.Walkspeed = 12
Humanoid.JumpPower = 45
end
end)
But as you can assume their will be times this doesn’t function properly depending if you time it right ( It’s hard but still possiable).
Could anyone please suggest me a new viable method!