local stun = Instance.new("BoolValue")
stun.Value = false
stun.Name = "stun"
stun.Parent = script.Parent
--7899158637
local stun = script.Parent:WaitForChild("stun")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7909878181"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid
local animationtrack = animator:LoadAnimation(animation)
--7919124865
local stunTime = Instance.new("NumberValue")
stunTime.Name = "StunTime"
stunTime.Value = 0.5
stunTime.Parent = script.Parent
local player = game.Players:FindFirstChild(script.Parent.Name)
local fists = player.Backpack.Fists
local db = true
stun.Changed:Connect(function()
if stun then
if db == true then
db = false
print(script.Parent.Name.." was stunned.")
humanoid.Parent.Activated.Value = false
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
fists.Enabled = false
animationtrack:Play()
wait(stunTime.Value)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoid.Parent.Activated.Value = true
fists.Enabled = true
db = true
end
elseif not stun then
humanoid.WalkSpeed = 16
end
end)
Hello, in the script above im making the player stunned when they get hit, but sometimes they get perma stunned and cant do anything.
local stun = Instance.new("BoolValue")
stun.Value = false
stun.Name = "stun"
stun.Parent = script.Parent
--7899158637
local stun = script.Parent:WaitForChild("stun")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7909878181"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationtrack = animator:LoadAnimation(animation)
--7919124865
local stunTime = Instance.new("NumberValue")
stunTime.Name = "StunTime"
stunTime.Value = 0.5
stunTime.Parent = script.Parent
local player = game.Players:FindFirstChild(script.Parent.Name)
local fists = player:WaitForChild("Backpack"):WaitForChild("Fists")
local debounce = true
stun.Changed:Connect(function()
if stun.Value then
if debounce then
return
end
debounce = false
print(script.Parent.Name.." was stunned.")
humanoid.Parent:WaitForChild("Activated").Value = false
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
fists.Enabled = false
animationtrack:Play()
task.wait(stunTime.Value)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoid.Parent:WaitForChild("Activated").Value = true
fists.Enabled = true
debounce = true
else
humanoid.WalkSpeed = 16
end
end)
stun would have always been true since it’s just a reference to an existing instance, stun.Value is where the boolean value is stored so you need to use that in the conditional instead.