Hello, I am making a voting system and I am making it so that you can only vote in one pad and removes your vote from the other pads. However when I spawn in, I have no tags, so :FindFirstChild(“VotingTag”) should return as false, however it is returning true and breaking my script. Can someone help? Thanks. Here is my current code:
local voters = {}
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not table.find(voters,plr) then
if plr.Character:FindFirstChild("VotingTag") then
local t = plr:FindFirstChild("VotingTag")
if t.Value ~= script.Parent.Name then
local find = workspace.Lobby:FindFirstChild(t.Value)
local n = tonumber(find.SurfaceGui.TextLabel.Text)-1
find.SurfaceGui.TextLabel.Text = tostring(n)
t.Value = script.Parent.Name
local new = tonumber(script.Parent.SurfaceGui.TextLabel.Text)+1
script.Parent.SurfaceGui.TextLabel.Text = tostring(new)
table.insert(voters,plr)
end
else
local tag = Instance.new("StringValue")
tag.Name = "VotingTag"
tag.Value = script.Parent.Name
tag.Parent = plr.Character
end
end
end
end)
Enjoy this chilly season!
-Earthraphobic2