How would i create an effective stun system?

Im updating one of my old Time Stop scripts, and im trying to go for a different approach for trying to stop player movement.

What i did last time was loop through the player model and anchor all baseparts, which was effective but i dont want to do that since it takes alot of scripting.

My friend told me that i should try “stunning” the person, and i did some digging in devforum and i didnt find much, all i found was that it involves changing the humanoids walkspeed to 0.

With this in mind you’d think it would be simple making a stun system, but for my time stop im using a hitbox, if whatever touches the hitbox has a humanoid it will freeze in time. and i dont think theres a function that detects if something isnt touching an object.

Regardless, i’m looking for a nice basic way to create a stun system. Help is much appreciated

Maybe something like this?

local stunned = false -- replace with bool if needed.
local timestunnedfor = 5
local hits = 0

local function Stun()
    if stunned == false then
        stunned = true
    end
    wait(timestunnedfor)
    stunned = false
end

while stunned == true do
    script.Parent.Humanoid.WalkSpeed = 0
end

if hits == 5 then
    Stun()
end
1 Like

how would this work? if hits = 0

The hits are inside a InputBegan connection

local UserInputService = game:GetService("UserInputService")
local hits = 0
UserInputService.InputBegan:Connect(function(i, g)
   if g then return end
   if i.UserInputType == Enum.UserInputType.MouseButton1 then
      hits += 1 -- increment hits
      if hits >= 5 then
         hits = 0
         Stun()
      end
   end
end)

I’ve made another reply that centers around on combos but maybe you can blend it in

1 Like