I was attempting to run my game after I had done some work on a LocalScript, right?
Before this point, everything worked perfectly normal, but when I went to playtest it, somehow, in some way, one of the core scripts suddenly not working.
I tested it again and again and the game refused to load.
I’m not sure if I should put this in bug reports or here, but I put it here just to be safe.
Here are my two main scripts, a TransitionHandler LocalScript and RoundHandler Script respectively:
local frame = script.Parent:WaitForChild("Transition").Frame
game.ReplicatedStorage.NewRoundPhase.OnClientEvent:Connect(function(phase, transition, yield)
if transition then
frame.AnchorPoint = Vector2.new(0,0.5)
frame.Position = UDim2.fromScale(0,0.5)
frame:TweenSize(UDim2.fromScale(1,2), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
task.wait(1.01)
end
if phase == "WritePoll" then
for i, child in ipairs(script.Parent.RoundFinish.ResultsFrame:GetChildren()) do
if child:IsA("TextLabel") then
child:Destroy()
end
end
script.Parent.PollAnswer.Enabled = false
script.Parent.PleaseWait.Enabled = false
script.Parent.Lobby.Enabled = false
script.Parent.PollCreate.Enabled = true
script.Parent.PollCreate.Question.Text = ""
script.Parent.PollCreate.AnswerA.Text = ""
script.Parent.PollCreate.AnswerB.Text = ""
script.Parent.PollCreate.AnswerC.Text = ""
script.Parent.PollCreate.AnswerD.Text = ""
script.Parent.Music.Lobby:Stop()
script.Parent.Music.PollWriting:Play()
elseif phase == "GivePoll" then
local p = script.Parent.PollCreate
game.ReplicatedStorage.GivePoll:FireServer(p.Question.Text, p.AnswerA.Text, p.AnswerB.Text, p.AnswerC.Text, p.AnswerD.Text)
elseif phase == "VotePoll" then
script.Parent.PollCreate.Enabled = false
script.Parent.PleaseWait.Enabled = false
script.Parent.Lobby.Enabled = false
script.Parent.PollAnswer.Enabled = true
script.Parent.PollAnswer.Author.Text = tostring("QUESTION FROM " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Author.Value .. ":")
script.Parent.PollAnswer.Question.Text = game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value
script.Parent.PollAnswer.Answers.AnswerA.Text = game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerA.Value
script.Parent.PollAnswer.Answers.AnswerB.Text = game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerB.Value
script.Parent.PollAnswer.Answers.AnswerC.Text = game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerC.Value
script.Parent.PollAnswer.Answers.AnswerD.Text = game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerD.Value
script.Parent.PollAnswer.SelectedAnswer.Text = ""
script.Parent.PollAnswer.Answers.AnswerA.Votes.Visible = false
script.Parent.PollAnswer.Answers.AnswerB.Votes.Visible = false
script.Parent.PollAnswer.Answers.AnswerC.Votes.Visible = false
script.Parent.PollAnswer.Answers.AnswerD.Votes.Visible = false
script.Parent.PollAnswer.Answers.Size = UDim2.fromScale(0.696,0.28)
for i, child in ipairs(script.Parent.PollAnswer.Answers:GetChildren()) do
if child:IsA("TextButton") then
child.Visible = true
if child.Text == "" then
child.Visible = false
end
end
end
script.Parent.Music.PollWriting:Stop()
local song = math.random(1,2)
if song == 1 then
script.Parent.Music.PollAnswerA:Play()
else
script.Parent.Music.PollAnswerB:Play()
end
elseif phase == "ShowResults" then
script.Parent.SFX.TimeUp:Play()
task.wait(1)
script.Parent.PollAnswer.Answers.AnswerA.Votes.Visible = true
script.Parent.PollAnswer.Answers.AnswerA.Votes.Text = tostring(#game.ReplicatedStorage.CurrentPoll.AnswerA:GetChildren() .. " votes")
script.Parent.PollAnswer.Answers.AnswerB.Votes.Visible = true
script.Parent.PollAnswer.Answers.AnswerB.Votes.Text = tostring(#game.ReplicatedStorage.CurrentPoll.AnswerB:GetChildren() .. " votes")
script.Parent.PollAnswer.Answers.AnswerC.Votes.Visible = true
script.Parent.PollAnswer.Answers.AnswerC.Votes.Text = tostring(#game.ReplicatedStorage.CurrentPoll.AnswerC:GetChildren() .. " votes")
script.Parent.PollAnswer.Answers.AnswerD.Votes.Visible = true
script.Parent.PollAnswer.Answers.AnswerD.Votes.Text = tostring(#game.ReplicatedStorage.CurrentPoll.AnswerD:GetChildren() .. " votes")
script.Parent.Music.PollAnswerA:Stop()
script.Parent.Music.PollAnswerB:Stop()
script.Parent.PollAnswer.Answers:TweenSize(UDim2.fromScale(0.796,0.33), Enum.EasingDirection.InOut, Enum.EasingStyle.Back)
local song = math.random(1,2)
if song == 1 then
script.Parent.Music.PollResultsA:Play()
else
script.Parent.Music.PollResultsB:Play()
end
local a = #game.ReplicatedStorage.CurrentPoll.AnswerA:GetChildren()
local b = #game.ReplicatedStorage.CurrentPoll.AnswerB:GetChildren()
local c = #game.ReplicatedStorage.CurrentPoll.AnswerC:GetChildren()
local d = #game.ReplicatedStorage.CurrentPoll.AnswerD:GetChildren()
local newtext = script.EndRoundAnswer:Clone()
newtext.Parent = script.Parent.RoundFinish.ResultsFrame
if a > b and a > c and a > d then
newtext.Text = tostring("The answer to " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value .. " is " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerA.Value)
elseif b > a and b > c and b > d then
newtext.Text = tostring("The answer to " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value .. " is " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerB.Value)
elseif c > a and c > b and c > d then
newtext.Text = tostring("The answer to " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value .. " is " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerC.Value)
elseif d > a and d > b and d > c then
newtext.Text = tostring("The answer to " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value .. " is " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.AnswerD.Value)
else
newtext.Text = tostring("The answer to " .. game.ReplicatedStorage.CurrentPoll.Poll.Value.Question.Value .. " is undecidable.")
end
elseif phase == "ShowRoundResults" then
script.Parent.RoundFinish.Enabled = true
script.Parent.PollAnswer.Enabled = false
script.Parent.Music.RoundResults:Play()
elseif phase == "Lobby" then
script.Parent.Music.Lobby:Play()
script.Parent.RoundFinish.Enabled = false
for i, child in ipairs(script.Parent.RoundFinish.ResultsFrame:GetChildren()) do
if child:IsA("TextLabel") then
child:Destroy()
end
end
script.Parent.Lobby.Enabled = true
end
if transition and not yield then
frame.AnchorPoint = Vector2.new(1,0.5)
frame.Position = UDim2.fromScale(1,0.5)
frame:TweenSize(UDim2.fromScale(0,2), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
task.wait(1.01)
end
end)
game.ReplicatedStorage.CancelWait.OnClientEvent:Connect(function()
frame.AnchorPoint = Vector2.new(1,0.5)
frame.Position = UDim2.fromScale(1,0.5)
frame:TweenSize(UDim2.fromScale(0,2), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
task.wait(1.01)
end)
txt = game:GetService("TextService")
pollnum = 0
game.ReplicatedStorage.GivePoll.OnServerEvent:Connect(function(plr, q, a1, a2, a3, a4)
pollnum += 1
local num = pollnum
local newq
local newa1
local newa2
local newa3
local newa4
local s, e = pcall(function()
newq = tostring(txt:FilterStringAsync(q, plr.UserId):GetChatForUserAsync(plr.UserId))
newa1 = tostring(txt:FilterStringAsync(a1, plr.UserId):GetChatForUserAsync(plr.UserId))
newa2 = tostring(txt:FilterStringAsync(a2, plr.UserId):GetChatForUserAsync(plr.UserId))
newa3 = tostring(txt:FilterStringAsync(a3, plr.UserId):GetChatForUserAsync(plr.UserId))
newa4 = tostring(txt:FilterStringAsync(a4, plr.UserId):GetChatForUserAsync(plr.UserId))
end)
if not s then
warn(e)
else
print("success")
end
local poll = script.Poll:Clone()
poll.Parent = game.ReplicatedStorage.Polls
poll.Name = tostring("Poll" .. pollnum)
poll.Author.Value = plr.Name
poll.AnswerA.Value = newa1
poll.AnswerB.Value = newa2
poll.AnswerC.Value = newa3
poll.AnswerD.Value = newa4
poll.Question.Value = q
end)
while true do
game.ReplicatedStorage.RoundInfo.Time.Value = 5--30
game.ReplicatedStorage.Polls:ClearAllChildren()
repeat
task.wait(1)
if #game.Players:GetPlayers() > 0 then-- > 2 then
game.ReplicatedStorage.RoundInfo.Time.Value -= 1
else
game.ReplicatedStorage.RoundInfo.Time.Value = 5--30
end
until game.ReplicatedStorage.RoundInfo.Time.Value <= 0
game.ReplicatedStorage.RoundInfo.Running.Value = true
game.ReplicatedStorage.NewRoundPhase:FireAllClients("WritePoll", true, false)
task.wait(1.01)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "WritePoll"
game.ReplicatedStorage.RoundInfo.Time.Value = 120
for i = 1, 10 do--120 do
task.wait(1)
game.ReplicatedStorage.RoundInfo.Time.Value -= 1
end
game.ReplicatedStorage.NewRoundPhase:FireAllClients("GivePoll", true, true)
repeat task.wait() until #game.ReplicatedStorage.Polls:GetChildren() >= #game.Players:GetPlayers()
task.wait(1.02)
--nice
game.ReplicatedStorage.CurrentPoll.Poll.Value = game.ReplicatedStorage.Polls:GetChildren()[1]
game.ReplicatedStorage.Polls:GetChildren()[1].Answered.Value = true
game.ReplicatedStorage.CancelWait:FireAllClients()
game.ReplicatedStorage.NewRoundPhase:FireAllClients("VotePoll", false, false)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "VotePoll"
game.ReplicatedStorage.RoundInfo.Time.Value = 30
for i, plr in ipairs(game.Players:GetPlayers()) do
local newinst = Instance.new("StringValue")
newinst.Name = plr.Name
newinst.Parent = game.ReplicatedStorage.CurrentPoll.Undecided
end
for i = 1, 30 do
task.wait(1)
game.ReplicatedStorage.RoundInfo.Time.Value -= 1
end
game.ReplicatedStorage.NewRoundPhase:FireAllClients("ShowResults", false, false)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "ShowResults"
task.wait(7)
game.ReplicatedStorage.CurrentPoll.AnswerA:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerB:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerC:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerD:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.Undecided:ClearAllChildren()
for i, child in ipairs(game.ReplicatedStorage.Polls:GetChildren()) do
local s, e = pcall(function()
if child.Answered.Value == false then
for i, plr in ipairs(game.Players:GetPlayers()) do
local newinst = Instance.new("StringValue")
newinst.Name = plr.Name
newinst.Parent = game.ReplicatedStorage.CurrentPoll.Undecided
end
game.ReplicatedStorage.CurrentPoll.Poll.Value = child
child.Answered.Value = true
game.ReplicatedStorage.NewRoundPhase:FireAllClients("VotePoll", true, false)
task.wait(2)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "VotePoll"
game.ReplicatedStorage.RoundInfo.Time.Value = 30
for i = 1, 30 do
task.wait(1)
game.ReplicatedStorage.RoundInfo.Time.Value -= 1
end
game.ReplicatedStorage.NewRoundPhase:FireAllClients("ShowResults", false, false)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "ShowResults"
task.wait(7)
game.ReplicatedStorage.CurrentPoll.AnswerA:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerB:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerC:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.AnswerD:ClearAllChildren()
game.ReplicatedStorage.CurrentPoll.Undecided:ClearAllChildren()
end
end)
if not s then
warn(e)
end
end
game.ReplicatedStorage.NewRoundPhase:FireAllClients("ShowRoundResults", true, false)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "ShowRoundResults"
task.wait(15)
game.ReplicatedStorage.NewRoundPhase:FireAllClients("Lobby", true, false)
game.ReplicatedStorage.RoundInfo.RoundPhase.Value = "Lobby"
end
(I’m sorry for my very brute force and messy code.)
I will provide any other scripts that may be requested to help me with the issue.