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

Enabled value not changing for a ScreenGui in a round game, know a fix?

Asked by 5 years ago

I tried making a round-based game that would edit each player's ScreenGui that had options to teleport around. It would cut it off for 60 seconds and cut it back on for 15 seconds.

while true do 

wait(15) 

local plrs = game.Players:GetChildren() 
for i = 1, #plrs do 
    plrs[i].Character.HumanoidRootPart.CFrame = workspace.gameSpawn.CFrame
    plrs[i].PlayerGui.tps.Enabled = false 
end

wait(60) 

local plrs = game.Players:GetChildren() 
for i = 1, #plrs do 
    plrs[i].PlayerGui.tps.Enabled = true 
end 
end

It won't turn Enabled to true or false. Anyone know the reason why?

0
Is tps a ValueObject?  This information could help me fix your problem saSlol2436 716 — 5y
0
"tps" is a ScreenGui User#28017 0 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

You need to add debounce:

local debounce = 0

while true do
    if debounce == 0
        debounce = 1
        wait(15) 
        local plrs = game.Players:GetChildren() 
        for i = 1, #plrs do 
            plrs[i].Character.HumanoidRootPart.CFrame = workspace.gameSpawn.CFrame
            plrs[i].PlayerGui.tps.Enabled = false 
        end
        wait(60) 
        local plrs = game.Players:GetChildren() 
        for i = 1, #plrs do 
            plrs[i].PlayerGui.tps.Enabled = true
        end
        debounce = 0
    end 
end
0
This should work. Let me know if it doesn't, and how it doesn't PaliKai13 92 — 5y
0
you forgot to change the debounce back to 0 btw User#28017 0 — 5y
Ad

Answer this question