If I have this piece of code in my game, which just makes a textbutton active and inactive during a intermission, my game becomes completely not joinable from the Roblox website. I can play in the studio but when the change from inactive to active happens, it freezes for 5 - 10 seconds.
Dose anyone know why this is happening or how to fix it?
while true do
if InRound.Value == false then
script.Parent.Active = false
wait(1)
if InRound.Value == true then
script.Parent.Active = true
I believe that you should change the wait(1) part. Try playing the game again in clirnt AFTER you edit this script by changing the wait(1) to wait(). Hope this helped.
It looks like you forgot to put the wait() at the top or bottom of the while true do code. Also you forgot to but the end at the back
It should go something like
while true do
--Code
wait() --How long you want your wait to be. The default is 0.03 seconds I think. But you can change that in studio settings.
end
local db = true
local player = game.Players.LocalPlayer
local target = game.Workspace.GameAreaSpawn
local delay = 0
local InRound = game.ReplicatedStorage.InRound
while true do
if InRound.Value == false then
script.Parent.Active = false
wait(1.5)
if InRound.Value == true then
script.Parent.Active = true
script.Parent.MouseButton1Click:connect (function()
if db == true then
db = false
player.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(0, 3, 0)
for i = delay, 1, -1 do
script.Parent.Text = 1
wait (1)
end
script.Parent.Text = "GameAreaSpawn" --for teleporting
db = true
end
script.Parent.Parent.Enabled = false
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
workspace.CurrentCamera.Blur.Enabled = false
end)
end
end
end
Like @Mitumitu17YN and @TwyPlasma said, You should add a wait(), This way the game won’t freeze due to running it infinite times.
while true do
if InRound.Value == false then
script.Parent.Active = false
wait(1)
if InRound.Value == true then
script.Parent.Active = true
end
end
wait()
end