My Voting system isn't working

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.

1 Like

Is there some kind of error that you get?

No, other than infinite yield possible on Workspace.Vote1

Where is the voting system stored?

In Workspace, but the script is in ServerScriptService, and the local script is in the surface gui for status.

Also I saw that you were doing,

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

You are setting vote 1,2 & 3’s Text to the Votes of Vote1

Oh, Lol I’ll go fix that and see what happens.

Then check for any sort of typo/etc,
Also instead of doing game.Workspace you can just do workspace,
you don’t need to put game.

Hmm, whenever i step on the voting platform it gives me this
15:50:40.375 - Infinite yield possible on ‘Workspace.VotingSystem:WaitForChild(“Vote1”)’

That won’t fix your original error.

That was the original error i just types it wrong. And it is the only error. Status doesn’t put “Seconds left to vote” in a screen gui like its suppose to on a text lable.

If you get Infinite yield possible on while doing WaitForChild(), It’s saying that “Vote1” doesn’t exist. As I said earlier, check for typos.

Vote1 does exist under that model, thats under something under the model.

By your logic,

local VotingSystem = game.Workspace:WaitForChild(“VotingSystem”)
local Vote1 = VotingSystem:WaitForChild(“Vote1”)

You are saying that Vote1 Is a child of VotingSystem.

So there is VotingSystem, and under VotingSystem is VoteDisplay, under VoteDisplay is ScreenGui, then under ScreenGui is Vote1, Vote2, and Vote3.

There’s your problem,

You are looking for Vote1 under VotingSystem, when it’s really under all of that.
Just add all of that and it should work.

If this solved your issue, please click the solved on my comment. Thank you :slightly_smiling_face:

Ok, thank you for your help. I always appreciate people who take time out of theier day to h elp others, i’ll go try it out.

1 Like

No worries!

Anyways, If your having problems with code following a tutorial. The code might be outdated, but. You can always check the comment section to see if other people are having the same issue, if not. You can just recheck your code.

im getting
18:05:12.135 - Votes is not a valid member of Frame

Read the error, Votes doesn’t exist in Frame.