Hello. Today, I am posting this because my vote system script does not work for some reason. Here is the first script located in a regular script.(and i got the tutorial off of the devking’s vid)
local VotingSystem = game.Workspace:WaitForChild(“VotingSystem”)
local Vote1 = VotingSystem:WaitForChild(“Vote1”)
local Vote2 = VotingSystem:WaitForChild(“Vote2”)
local Vote3 = VotingSystem:WaitForChild(“Vote3”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local TimeLeft = ReplicatedStorage:WaitForChild(“TimeLeft”)
local DoneVoting = ReplicatedStorage:WaitForChild(“DoneVoting”)
game.Players.PlayerAdded:Connect(function(player)
local Vote = Instance.new("StringValue")
Vote.Name = "Vote"
Vote.Parent = player
Vote.Value = "NA"
end)
local function updateDisplay()
VotingSystem.VoteDisplay.SurfaceGui.Vote1.Counter.Text = Vote1.Votes.Value
VotingSystem.VoteDisplay.SurfaceGui.Vote2.Counter.Text = Vote1.Votes.Value
VotingSystem.VoteDisplay.SurfaceGui.Vote3.Counter.Text = Vote1.Votes.Value
end
for i, Pad in pairs(game.Workspace.VotingSystem:GetChildren()) do
if Pad.Name ~= “VotingDisplay” then
Pad.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local char = hit.Parent
local Player = game.Players:GetPlayerFromCharacter(char)
if Player.Vote.Value ~= Pad then
Pad.Votes.Value = Pad.Votes.Value + 1
if Player.Vote.Value ~= "NA" then
local padToSubtract = VotingSystem:FindFirstChild(Player.Vote.Value)
padToSubtract.Votes.Value = padToSubtract.Votes.Value - 1
end
Player.Vote.Value = Pad.Name
updateDisplay()
end
end
end)
end
end
spawn(function()
while wait(1) do
if TimeLeft.Value <= 0 then
DoneVoting.Value = true
wait(5)
TimeLeft.Value = 10
DoneVoting.Value = false
end
TimeLeft.Value = TimeLeft.Value - 1
end
end)
And here is the second script inside of a local script.
local Status = script.Parent:WaitForChild(“Status”)
local VotingSystem = game.Workspace:WaitForChild(“VotingSystem”)
local Pad1 = VotingSystem:WaitForChild(“Vote1”)
local Pad2 = VotingSystem:WaitForChild(“Vote2”)
local Pad3 = VotingSystem:WaitForChild(“Vote3”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local TimeLeft = ReplicatedStorage:WaitForChild(“TimeLeft”)
local DoneVoting = ReplicatedStorage:WaitForChild(“DoneVoting”)
local function CalculateWinner()
local padVotes = {
[“Pad1”] = Pad1.Votes.Value,
[“Pad2”] = Pad2.Votes.Value,
[“Pad3”] = Pad3.Votes.Value,
}
local highest = 0
local pad = nil
for i, V in pairs(padVotes) do
if V > highest then
highest = V
pad = i
end
end
return pad
end
TimeLeft.Changed:Connect(function()
Status.Text = TimeLeft.Value … " seconds left to vote!"
end)
DoneVoting.Changed:Connect(function()
local Winner = CalculateWinner()
if Winner == nil then
Status.Text = “It was a tie! Vote Again”
else
Status.Text = Winner… “Got the most votes!”
end
end)
Any help will be appreciated.