Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What Would Be the Best Way to Make a Vote to Fix Function?

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

2 comments

1

Instead of a vote to fix, fix the problems in the first place.

0

Scripts cannot run in ServerStorage, that is your first issue. Next you're probably going to need some info on RemoteEvents because you're going to need them for this. 

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.