when a player joins the game the game inserts a folder with a bool value: "hasvoted",
game.Players.PlayerAdded:connect(function(player) local settings = Instance.new("Folder",player) settings.Name = "Settings" local afk = Instance.new("BoolValue",settings) afk.Name = "hasvoted" end)
now, whenever a player touches a part (to vote) how to I access this to check if he has or has not? this is my code so far, but it does not work:
script.Parent.Touched:connect(function(p) if game.Players:GetPlayerFromCharacter(p.Parent) then local player = game.Players:GetPlayerFromCharacter(p.Parent) if player.Settings.hasvoted == false then print("Player Voted.") elseif player.Settings.hasvoted == true then reply.Text = "You have already voted for an event!" end end end)
You're comparing the object hasvoted
with a bool value, but you're wanting to compare its value to it.
script.Parent.Touched:connect(function(p) if game.Players:GetPlayerFromCharacter(p.Parent) then local player = game.Players:GetPlayerFromCharacter(p.Parent) if player.Settings.hasvoted.Value == false then print("Player Voted.") elseif player.Settings.hasvoted.Value == true then reply.Text = "You have already voted for an event!" end end end)