Weird thing going on

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

Hope y’all have a great day! Stay safe

1 Like

This is probably because there is a line that does this:

script.Parent.Teams.Text = Teams.Value .. " Votes"

and it is setting the text of the button to the number of votes there are, OR:

there are 2 GuiObjects named “Teams”, and they are conflicting.

Well I know that I don’t have two team gui objects

1 Like

Then, go into your while wait() do loop and try to get rid of that line I listed in my previous reply. That might work.

Ok but now I can’t vote (30char)

1 Like

Did you make sure you got rid of the right line? Go & check, maybe you got rid of the wrong line.

wait just that line or both that line and the line below as well?

1 Like

Just get rid of this line:

script.Parent.Teams.Text = Teams.Value .. " Votes"

in your loop.

Now I can vote for “Classic” but not “Teams”

1 Like

Post your code, I might be able to figure it out.

I did, it is above. (30 characters)

1 Like

I mean post your new code, not the old code.

 '''
          -- 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



      '''

You have to format it correctly like this:
`` `lua

`` `
Don’t use spaces in between the ```.

There that’s what it looks like

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.

2 Likes

Never mind… I realized I made a stupid mistake:

   '''
            -- correct way
           while wait() do
           script.Parent.Visible = true
           script.Parent.Classic.TextLabel.Text = Classic.Value .." Votes"
           script.Parent.Teams.TextLabel.Text = Teams.Value .." Votes"
           end

        '''