My game is currently in Beta and has a habit of breaking; I thought for the meantime, until the errors are fixed, I can install a function for voting to fix the game by the players. I thought of accomplishing this by making it so that the main script that runs the game is cloned and the original copy is deleted and replaced with the new one. However, when I do that, the new script just doesn't run. Why is that?
For the button:
script.Parent.MouseButton1Up:connect(function() local value = script.Parent.Parent.Vote if value.Value == true then value.Value = false else value.Value = true end end
For the game reset:
--In the ServerStorage while wait(.1) do getPlayers = game.Players:GetChildren() for i, v in pairs(getPlayers) do if v.PlayerGui:FindFirstChild("FixButton") then if v.PlayerGui.FixButton.Vote.Value == true then script.Parent.Vote.Value = script.Parent.Vote.Value + 1 end end end if script.Parent.Vote.Value >= math.floor(#(game.Players:GetChildren())*.75) then replaceScript = game.Workspace.MainScript:Clone() replaceScript.Disabled = true game.Workspace.MainScript:Destroy() getPlayers2 = game.Players:GetChildren() for i, v in pairs(getPlayers2) do if v.PlayerGui:FindFirstChild("FixButton") then v.PlayerGui.FixButton.Vote.Value = 0 end end replaceScript.Parent = game.Workspace replaceScript.Disabled = false end end
If you really want to do this, have the script start when an event is called and call that event upon cloning the script. Also: Scripts don't run in ServerStorage. Put it somewhere else.
What you should be doing instead of this is fixing your script. If it has a habit of breaking then figure out why and solve that problem.