You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
a stun so every time player gets hit they cant move/jump for a period of time, the script is set in a module and is called from client side.
Observe how the walk speed changes on the right side panel in the video
and i just realized u can walk out of the stun when u press the D key i don’t know why or how this is happening i have no conflicting scripts i checked
- What is the issue?
for some reason when i don’t move and get hit it works fine, but if I’m moving and i get hit i can still move almost like the repeat function is going off
- What solutions have you tried so far?
nothing to try
local Controller = {}
local activeWalkCoroutine
local activeJumpCoroutine
Controller.State = function(Humanoid, Duration)
local Character = Humanoid.Parent
if activeWalkCoroutine and coroutine.status(activeWalkCoroutine) ~= "dead" then
coroutine.close(activeWalkCoroutine)
end
if activeJumpCoroutine and coroutine.status(activeJumpCoroutine) ~= "dead" then
coroutine.close(activeJumpCoroutine)
end
Humanoid.JumpHeight = 0
repeat
task.wait()
Humanoid.WalkSpeed = 0
Duration -= 1
until Duration <= 0
activeWalkCoroutine = coroutine.create(function()
task.wait(1)
Humanoid.WalkSpeed = 16
end)
coroutine.resume(activeWalkCoroutine)
activeJumpCoroutine = coroutine.create(function()
task.wait(0.25)
Humanoid.JumpHeight = 7.2
end)
coroutine.resume(activeJumpCoroutine)
end
return Controller