Hey guys! I hope y’all do very very well! Being direct, I have 2 problems, 1 is that the countdown system doesn’t start, and the other is that the voting system in general doesn’t activates.
I know there’s a lot of good people here in the devforum, and I’ll appreciate a lot if you can give me a hand with this, if you are experienced or not, even if it’s a little one, have a nice day!
Here’s the Client Script (LocalScript) Code:
local Vote = game.ReplicatedStorage:WaitForChild('RemoteEvents').Vote
local chosen
--Vote for Player1--
script.Parent.Player1.TextButton.MouseButton1Click:Connect(function()
if chosen ~= "VoteForPlayer1" then
game.ReplicatedStorage:WaitForChild('RemoteEvents').Vote:FireServer(chosen, "VoteForPlayer1")
chosen = "VoteForPlayer1"
end
end)
--Vote for Player1--
--Vote for Player2--
script.Parent.Player2.TextButton.MouseButton1Click:Connect(function()
if chosen ~= "VoteForPlayer2" then
game.ReplicatedStorage:WaitForChild('RemoteEvents').Vote:FireServer(chosen, "VoteForPlayer2")
chosen = "VoteForPlayer2"
end
end)
--Vote for Player2--
--Vote for Player3--
script.Parent.Player3.TextButton.MouseButton1Click:Connect(function()
if chosen ~= "VoteForPlayer3" then
game.ReplicatedStorage:WaitForChild('RemoteEvents').Vote:FireServer(chosen, "VoteForPlayer3")
chosen = "VoteForPlayer3"
end
end)
--Vote for Player3--
And like this up to Player 7
ServerScript(Normal Script) Code:
game.ReplicatedStorage:WaitForChild('RemoteEvents').Vote.OnServerEvent:Connect(function(player, Previous, chosen)
local Votes = game.ReplicatedStorage:WaitForChild('VoteFor')[chosen]
Votes = Votes.Value + 1
if Previous ~= nil then
local Previous = game.ReplicatedStorage:WaitForChild('VoteFor')[Previous]
Previous = Previous.Value - 1
end
end)
local votes = {
game.ReplicatedStorage.VoteFor.VoteForPlayer1;
game.ReplicatedStorage.VoteFor.VoteForPlayer2;
game.ReplicatedStorage.VoteFor.VoteForPlayer3;
game.ReplicatedStorage.VoteFor.VoteForPlayer4;
game.ReplicatedStorage.VoteFor.VoteForPlayer5;
game.ReplicatedStorage.VoteFor.VoteForPlayer6;
game.ReplicatedStorage.VoteFor.VoteForPlayer7;
game.ReplicatedStorage.VoteFor.VoteForPlayer8;
game.ReplicatedStorage.VoteFor.VoteForPlayer9;
game.ReplicatedStorage.VoteFor.VoteForPlayer10;
game.ReplicatedStorage.VoteFor.VoteForPlayer11;
game.ReplicatedStorage.VoteFor.VoteForPlayer12;
}
local Timer2 = game.ReplicatedStorage.Timer2
for i = 45, 0, -1 do
Timer2.Value = i
wait(1)
end
table.sort(votes, function(a, b, c, d, e, f, g, h, i, j, k, l)
return a.Value > b.Value and c.Value and d.Value and e.Value and f.Value and g.Value and h.Value and i.Value and j.Value and k.Value and l.Value
end)
local chosen = votes[1].Name
if chosen == "VoteForPlayer1" then
--Darle el Mayor a la persona escogida ganada
print('Player1 was choosed !')
elseif chosen == "VoteForPlayer2" then
--Darle el Mayor a la persona escogida ganada
print('Player2 was choosed !')
elseif chosen == "VoteForPlayer3" then
--Darle el Mayor a la persona escogida ganada
print('Player3 was choosed !')
elseif chosen == "VoteForPlayer4" then
--Darle el Mayor a la persona escogida ganada
print('Player4 was choosed !')
elseif chosen == "VoteForPlayer5" then
--Darle el Mayor a la persona escogida ganada
print('Player5 was choosed !')
elseif chosen == "VoteForPlayer6" then
--Darle el Mayor a la persona escogida ganada
print('Player6 was choosed !')
elseif chosen == "VoteForPlayer7" then
--Darle el Mayor a la persona escogida ganada
print('Player7 was choosed!')
end
Errors that I noticed :
-
Timer2.Value is equal to 0 (Even that I manually put 45 as the default value {before starting the game})
-
When you click on the UI buttons it doesn’t change the “VoteForPlayerX” value
I appreciate your help even if it’s the smallest one, have a nice day!