Hello I’m making a voting system and this weird thing happens when I test the game… robloxapp-20200620-1547047.wmvAnyway, here are the scripts:
-- local script child of frame
local Classic = game.ReplicatedStorage.Classic
local Teams = game.ReplicatedStorage.Teams
local VotingOn = game.ReplicatedStorage.VotingOn
local status = game.ReplicatedStorage.VotingStatus
local chosen
script.Parent.Classic.MouseButton1Click:Connect(function()
if chosen ~= "Classic" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Classic")
chosen = "Classic"
end
end)
script.Parent.Teams.MouseButton1Click:Connect(function()
if chosen ~= "Teams" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Teams")
chosen = "Teams"
end
end)
while wait() do
script.Parent.Visible = true
script.Parent.Status.Text = Classic.Value .." Votes"
script.Parent.Teams.Text = Teams.Value .. " Votes"
end
-- serverscript 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)
wait(1)
for i = 10,1,-1 do
game.ReplicatedStorage.VotingStatus.Value = i .. " seconds left 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 child of frame
local Classic = game.ReplicatedStorage.Classic
local Teams = game.ReplicatedStorage.Teams
local VotingOn = game.ReplicatedStorage.VotingOn
local status = game.ReplicatedStorage.VotingStatus
local chosen
script.Parent.Classic.MouseButton1Click:Connect(function()
if chosen ~= "Classic" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Classic")
chosen = "Classic"
end
end)
script.Parent.Teams.MouseButton1Click:Connect(function()
if chosen ~= "Teams" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Teams")
chosen = "Teams"
end
end)
while wait() do
script.Parent.Visible = true
script.Parent.Status.Text = Classic.Value .." Votes"
end
-- serverscript 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)
wait(1)
for i = 10,1,-1 do
game.ReplicatedStorage.VotingStatus.Value = i .. " seconds left 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
'''
Can you explain what exactly is wrong, not just post a video that doesn’t embed and say “Weird thing”? Most people won’t want to commit to the effort of downloading an entire video just to see if they might be able to help with a problem.