So, I was making a script to teleport players into a car, and I could not figure out for the life of me why I was getting this error:
14:39:18.497 - Workspace.Part.Script:53: attempt to call a userdata value 14:39:18.498 - Stack Begin 14:39:18.499 - Script 'Workspace.Part.Script', Line 53 14:39:18.499 - Stack End
This is my script I was using:
local this = script.Parent local transporting = false --Get all the seats available for sitting function getAllSeats() frontSeats = {} backSeats = {} --Get all front seats in cars for key,value in pairs (workspace.TransportJeep1.FrontJeep:GetChildren()) do if value:IsA("Seat") then table.insert(frontSeats,#frontSeats + 1,value) end end for key,value in pairs (workspace.TransportJeep.FrontJeep:GetChildren()) do if value:IsA("Seat") then table.insert(frontSeats,#frontSeats + 1,value) end end --Get all back seats in car for key,value in pairs (workspace.TransportJeep1.BackWall:GetChildren()) do if value:IsA("Seat") then table.insert(backSeats,#backSeats + 1,value) end end for key,value in pairs (workspace.TransportJeep.BackWall:GetChildren()) do if value:IsA("Seat") then table.insert(backSeats,#backSeats + 1,value) end end end function assignToSeat(part) local rootpart = part.Parent:FindFirstChild("HumanoidRootPart") local seatToAssign if #frontSeats > 0 then seatToAssign = frontSeats[math.random(1,#frontSeats)] rootpart.CFrame = CFrame.new(seatToAssign.Position) return true end if #backSeats > 0 then seatToAssign = backSeats[math.random(1,#backSeats)] rootpart.CFrame = CFrame.new(seatToAssign.Position) return true end return false end this.Touched(function(part) assignToSeat(part) end)
Any help would be greatly appreciated!
Just saying, I figured out the answer. I forgot connect :(. Thank you Benbebop for trying to help, I greatly appreciate that.