Workspace.TeleportScript:67: invalid argument #1 to 'find' (table expected, got Instance)

I am making a roblox roulette game where it sends you to random games.I am currently working on the voting system and cant figure out how to make it so you can’t vote for both but can only voter for one.
I have looked on the internet but nothings really helped me

Here is my code:

local PlaceIDs = require(game.ServerScriptService.Places)

local Players = game:GetService("Players")

local timer = game.Workspace.Platform.Screen.Time.SurfaceGui.TextLabel
local timeleft = 0

local teleportID = game.ReplicatedStorage.GameID

local green = game.Workspace.Platform.Buttons.Green
local red = game.Workspace.Platform.Buttons.Red
local yesVotes = game.ReplicatedStorage.Votes.YesVotes
local noVotes = game.ReplicatedStorage.Votes.NoVotes


local voting = function ()
	
	local votedYes = {}
	local AlreadyInYesTable = false
	
	local votedNo = {}
	local AlreadyInNoTable = false
	
	green.Touched:Connect(function(TouchedPart)
		if TouchedPart.Parent:FindFirstChild("Humanoid") then
			local Character = TouchedPart.Parent
			AlreadyInYesTable = false
			local Player = game.Players:GetPlayerFromCharacter(Character)
			
			for _,OtherPlayer in next,votedYes do
				if OtherPlayer == Player then
					AlreadyInYesTable = true
				end
			end
			
			if not AlreadyInYesTable then
				table.insert(votedYes,Player)
				yesVotes.Value = yesVotes.Value + 1
			end
			
			if AlreadyInNoTable then
				AlreadyInNoTable = false
				noVotes.Value = noVotes.Value - 1
				table.remove(votedNo,Player)
			end
		end
	end)
	
	red.Touched:Connect(function(TouchedPart)
		if TouchedPart.Parent:FindFirstChild("Humanoid") then
			local Character = TouchedPart.Parent
			local Player = game.Players:GetPlayerFromCharacter(Character)
			AlreadyInNoTable = false
			
			for _,OtherPlayer in next,votedNo do
				if OtherPlayer == Player then
					AlreadyInNoTable = true
				end
			end
			
			if not AlreadyInNoTable then
				table.insert(votedNo,Player)
				noVotes.Value = noVotes.Value + 1
			end
			if AlreadyInYesTable then
				AlreadyInYesTable = false
				local YesPosition = table.find(yesVotes,Player)
				yesVotes.Value = yesVotes.Value - 1
				table.remove(votedYes,YesPosition)
			end
		end
	end)
end


while true do
	wait()
	if timeleft <= 0 then
		timeleft = 30
		wait(2.5)
		timer.Text = "30"
		voting()
		PlaceIDs.ChooseRandom()
		wait()
		repeat
			timeleft -= 1
			timer.Text = timeleft
			wait(1)
		until timeleft == 0

	end
end

Thank you!

Can you try to do yesVotes:GetChildren() instead of just yesVotes for the table.find() function?

how would i get the number value as i need it to delete the person off the table

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.