Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I stop a value from changing?

Asked by 2 years ago
Edited 2 years ago

I want to stop a value changing so the stun wont become false during wait. (Without using loops otherwise it crashes the game/makes it really laggy)

--V is a character
--Stunned is a bool value

task.spawn(function()
    v.Stunned.Value = true  
    --v.Stunned.CanChange = false
    wait(stunTime)
    --v.Stunned.CanChange = true
    v.Stunned.Value = false 
end)
0
Are u 100% sure its happening during the wait? Jay123abc2 241 — 2y
0
You could create a second bool value named StunnedCanChange, and set and check that when you want WoTrox 345 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Ah, a stunned system. I just struggled with one of this a little while ago. The fix I came up with was not letting the player get stunned if they are already stunned.

if v.Stunned == true then return else
    v.Stunned.Value = true
    task.wait(stunTime)
    v.Stunned.Value = false
end

If this wasn't what you needed sorry, but this is what I did for my system.

Ad

Answer this question