I wanted to make my own stun handler for my game, without using the popular module. Anyways, I know how to set the stun, but I don’t know how to make the status update upon being hit again.
I just need someone to give me a rundown on how to do this. I’m thinking of making a runservice connection and using os.clock() but I’m not sure how to implement this.
Here’s what I’ve made thus far:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local AnimationFolder = ReplicatedStorage.Assets.Animations.StunAnimations
local StunTable = {}
local StunHandler = {}
local Stunanimations = {
AnimationFolder:WaitForChild("Stun1"),
AnimationFolder:WaitForChild("Stun2"),
AnimationFolder:WaitForChild("Stun3"),
AnimationFolder:WaitForChild("Stun4")
}
function StunHandler:RidStun(char)
local Stunned = char:GetAttribute("Stunned")
if Stunned then
StunTable[char] = false
char:SetAttribute("Stunned", false)
end
end
function StunHandler:Trigger(char, stuntime)
local Stunned = char:GetAttribute("Stunned")
local hum = char:WaitForChild("Humanoid")
if not Stunned and StunTable[char] == nil then
print("Applied")
char:SetAttribute("Stunned", true)
StunTable[char] = stuntime
task.wait(stuntime)
print("Rid")
StunTable[char] = nil
char:SetAttribute("Stunned", false)
end
end
return StunHandler