Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by
8391ice 91
7 years ago

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
1
Instead of a vote to fix, fix the problems in the first place. IcedVapour 153 — 7y
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.  StoIid 364 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago

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.

Ad

Answer this question