Function not repeating when It's supposed to

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

What are you trying to do?

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.

Is EndGame supposed to be in game or game.Workspace?

EndGame is the name of a part in the workspace.

while true do
if game.Workspace.EndGame.Transparency == 1 then
game.Workspace.EndGame.Transparency = 0

Oh I didn’t even realize I didn’t add workspace- let me see if that fixes it

If post #7 doesn’t work, can I see the full script?

It didn’t help it, here’s the full script:

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)

Can I see the seperate part?---------

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)

Will the script stay running?------

It does, the rest of the Script functions like intended.

Why do you need to check for the transparency?

Just so that the round will repeat when it’s touched.

Do you possibly have something I can test, because it’s a bit confusing.

The game is running, I can send you the link if thats what you meant by test

1 Like

I’m taking that like as a yes lol-

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
1 Like