Stun System is not working

I have this stun system im working with but it seems like its not working

The problem is that the stun is getting created and on the client it says that the walkspeed and jumppower is 0 but i am still able to move.

Also if I change the walkspeed to 0 on the server it immeaditly goes back to 16 when the Stun value is in the character.

This confuses me because the else statement is running while the current if statement that makes the walkspeed 0 is also running?

Any Help?

  • Local Script That Handles Stun
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")

RunService.RenderStepped:Connect(function()
    if Character:FindFirstChild("Stun") or Character:FindFirstChild("eStun") then
        Humanoid.WalkSpeed = 0
        Humanoid.JumpPower = 0
        print(Humanoid.WalkSpeed, Humanoid.JumpPower)
    else
        Humanoid.WalkSpeed = 16
        Humanoid.JumpPower = 50
    end
    if Character:FindFirstChild("Slowed") or Character:FindFirstChild("eSlowed") then
        Humanoid.WalkSpeed = 4
        Humanoid.JumpPower = 25
    else
        Humanoid.WalkSpeed = 16
        Humanoid.JumpPower = 50
    end
end)
  • How I create the Stun ( Module Script )
    local Time = TempTime or 1
    local RemovedCheck = false
    local Stun = Instance.new("BoolValue")


    Stun.Name = "Stun"
    Stun.Parent = EnemyChar

    Stun.AncestryChanged:Connect(function()
        if Stun.Parent ~= Stun and RemovedCheck == false and game.Players:GetPlayerFromCharacter(EnemyChar) then 
            game.Players:GetPlayerFromCharacter(EnemyChar):Kick("Exploiting: No Stun. Contact our team moderation if this was a error if not appeal in our contact server")
        end
    end)
    task.wait(Time)
    RemovedCheck = true
    Stun:Destroy()
  • How I use the module function in a regular script
local CombatReference = require(game.ReplicatedStorage.CombatReference)


local StunEffect = coroutine.create(function() CombatReference:GetStun(script.Parent,10) end)
coroutine.resume(StunEffect)

It’s beause this is running after you set the player’s Walkspeed. The Walkspeed is set, but only for a fraction of a second, because it then runs this statement, see’s that it’s false, and run’s the stuff in the else section, which returns the Walkspeed to normal. Just make this an elseif, like so:

    if Character:FindFirstChild("Stun") or Character:FindFirstChild("eStun") then
        Humanoid.WalkSpeed = 0
        Humanoid.JumpPower = 0
        print(Humanoid.WalkSpeed, Humanoid.JumpPower)
    elseif Character:FindFirstChild("Slowed") or Character:FindFirstChild("eSlowed") then
        Humanoid.WalkSpeed = 4
        Humanoid.JumpPower = 25
    else
        Humanoid.WalkSpeed = 16
        Humanoid.JumpPower = 50
    end
1 Like

Thanks For the clarification this really helped!

1 Like