Ok ok ok, I know I have already posted a topic on this, but this is a different issue but on the same script(s). I don’t know what is wrong, it prints “Classic” as soon as I join the game even though it is supposed to wait 20 seconds before doing so. Please point out any errors. Thanks!
-- server script in serverscriptservice
game.ReplicatedStorage.Vote.OnServerEvent:Connect(function(player, previous, chosen)
local votes = game.ReplicatedStorage[chosen]
votes.Value = votes.Value + 1
if previous ~= nil then
local prev = game.ReplicatedStorage[previous]
prev.Value = prev.Value - 1
end
end)
game.ReplicatedStorage.VotingOn.Value = true
for i = 20,1-1 do
game.ReplicatedStorage.VotingStatus.Value = i .." seconds to vote"
wait(1)
end
game.ReplicatedStorage.VotingOn.Value = false
local votes = {game.ReplicatedStorage.Classic, game.ReplicatedStorage.Teams}
table.sort(votes, function(a,b)
return a.Value > b.Value
end)
local chosen = votes[1].Name
if chosen == "Classic" then
print("Classic")
else
print("Teams")
end
-- local script in a frame
local Classic = game.ReplicatedStorage.Classic
local Teams = game.ReplicatedStorage.Teams
local VotingOn = game.ReplicatedStorage.VotingOn
local status = game.ReplicatedStorage.VotingStatus
local Vote = game.ReplicatedStorage.Vote
local chosen
script.Parent.Classic.MouseButton1Click:Connect(function()
if chosen ~= "Classic" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Classic")
chosen = "Classic"
script.Parent.Visible = false
end
end)
script.Parent.Teams.MouseButton1Click:Connect(function()
if chosen ~= "Teams" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Teams")
chosen = "Teams"
script.Parent.Visible = false
end
end)
while wait() do
script.Parent.Classic.TextLabel.Text = Classic.Value .." Votes"
script.Parent.Teams.TextLabel.Text = Teams.Value .." Votes"
end