Why isn’t my script repeating when It’s supposed to?
while true do
if game.EndGame.Transparency == 1 then
game.EndGame.Transparency = 0
It works the first time as the EndGame part is automatically set to 1 Transparency. However, once it’s re-set to 1 Transparency later it does not repeat.
Please help.
while true do
if game.EndGame.Transparency == 1 then
game.EndGame.Transparency = 0
end
if game.EndGame.Transparency == 0 then
game.EndGame.Transparency = 1
end
make sure both this script and whatever you’re using to set the property are on the same side (clientside or serverside)
if you’re setting the property in the explorer without changing the studio view to serverside, you’re setting the property only on clientside, so if this script is a server script, it won’t replicate
The function starts a round. Once the winner pad is touched the EndGame part’s Transparency is set back to 1. However, once it’s set back to 1 the function does not repeat.
local Map1 = game.ReplicatedStorage.Maps.Home
local Map2 = game.ReplicatedStorage.Maps.Tree
local a = 0
local b = 0
local c = 1
local d = 30
local status = game.ReplicatedStorage:WaitForChild(“Status”)
local z = 1
local f = 1
game.Workspace.HouseVote.ClickDetector.MouseClick:Connect(function()
a = a + 1
end)
game.Workspace.TreeVote.ClickDetector.MouseClick:Connect(function()
b = b + 1
end)
while true do
if game.Workspace.EndGame.Transparency == 1 then
game.Workspace.EndGame.Transparency = 0
status.Value = “Intermission!”
wait(40)
status.Value = “Starting Soon!”
wait(10)
status.Value = “Game in Progress!”
local players = game.Players:GetChildren()
for i, player in pairs(game.Players:GetPlayers()) do
local character = player.Character or player.CharacterAdded:Wait()
character:MoveTo(game.Workspace:WaitForChild(‘MapPart’).Position)
end
if a >= b then
local Clone = Map1:Clone()
Clone.Parent = game.Workspace
local Winner = Clone:WaitForChild(“Winner”)
Winner.Touched:Connect(function(hit)
local PlayerW = hit.Parent
local noob = PlayerW.Name
game.Players.noob.leaderstats.Wins.Value = game.Players.noob.leaderstats.Wins.Value + 1
end)
elseif b > a then
local Clone = Map2:Clone()
Clone.Parent = game.Workspace
local Winner = Clone:WaitForChild(“Winner”)
Winner.Touched:Connect(function(hit)
local PlayerW = hit.Parent
local noob = PlayerW.Name
game.Players.Noob.leaderstats.Wins.Value = game.Players.Noob.leaderstats.Wins.Value + 1
end)
end
end
end
(A separate script changes the Part back to Transparency 1 when it’s touched, that works normally)
script.Parent.Touched:Connect(function()
script.Parent:Destroy()
game.ReplicatedStorage.Status.Value = “Game Over!”
wait(5)
for i, player in pairs(game.Players:GetPlayers()) do
local character = player.Character or player.CharacterAdded:Wait()
character:MoveTo(game.Workspace:WaitForChild(‘SpawnLocationA’).Position)
end
game.Workspace.EndGame.Transparency = 1
end)
local Map1 = game:GetService("ReplicatedStorage").Maps.Home
local Map2 = game:GetService("ReplicatedStorage").Maps.Tree
local a = 0
local b = 0
local c = 1
local d = 30
local status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
local z = 1
local f = 1
game.Workspace.HouseVote.ClickDetector.MouseClick:Connect(function()
a += 1
end)
game.Workspace.TreeVote.ClickDetector.MouseClick:Connect(function()
b += 1
end)
game.Workspace.EndGame:GetPropertyChangedSignal("Transparency"):Connect(function()
if game.Workspace.EndGame.Transparency == 1 then
game.Workspace.EndGame.Transparency = 0
status.Value = "Intermission!"
wait(40)
status.Value = "Starting Soon!"
wait(10)
status.Value = "Game in Progress!"
local players = game.Players:GetChildren()
for i, player in pairs(game.Players:GetPlayers()) do
local character = player.Character or player.CharacterAdded:Wait()
character:MoveTo(game.Workspace:WaitForChild("MapPart").Position)
end
if a >= b then
local Clone = Map1:Clone()
Clone.Parent = game.Workspace
local Winner = Clone:WaitForChild("Winner")
Winner.Touched:Connect(function(hit)
local PlayerW = hit.Parent
local noob = PlayerW.Name
game.Players.noob.leaderstats.Wins.Value = game.Players.noob.leaderstats.Wins.Value + 1
end)
elseif b > a then
local Clone = Map2:Clone()
Clone.Parent = game.Workspace
local Winner = Clone:WaitForChild("Winner")
Winner.Touched:Connect(function(hit)
local PlayerW = hit.Parent
local noob = PlayerW.Name
game.Players.Noob.leaderstats.Wins.Value = game.Players.Noob.leaderstats.Wins.Value + 1
end)
end
end
end)
game.Workspace.EndGame.Transparency = 1