This errors and says "Character is not a valid member of part"
seats = {1,2,3,4,5,6,7,8,9,10}
function untilRSeat()
local breakit = false
for i = 1, #seats do
if game.Workspace:FindFirstChild(i).occupied.Value == false then
game.Workspace:FindFirstChild(i).occupied.Value = true
breakit = true
print(i)
return i
end
if breakit == true then
break
end
end
end
game.Players.PlayerAdded:connect(function(p)
print(p.Name)
local player = p
p:WaitForDataReady()
seat = game.Workspace:FindFirstChild(untilRSeat())
print(seat.Name)
local cams = script.LocalScript:Clone()
cams.ObjectValue.Value = seat:FindFirstChild("Head")
cams.Parent = p
cams.Disabled = false
print("Disabled")
p.CameraMaxZoomDistance = 20
local rac = p.Character:FindFirstChild("Right Arm").BrickColor.Name
local lac = p.Character:FindFirstChild("Left Arm").BrickColor.Name
local tc = p.Character:FindFirstChild("Torso").BrickColor.Name
local hc = p.Character:FindFirstChild("Head").BrickColor.Name
local rlc = p.Character:FindFirstChild("Right Leg").BrickColor.Name
local llc = p.Character:FindFirstChild("Left Leg").BrickColor.Name
if p.Character:FindFirstChild("Shirt") ~= nil then
local shirt = p.Character.Shirt.ShirtTemplate
end
if p.Character:FindFirstChild("Pants") ~= nil then
local pants = p.Character.Pants.PantsTemplate
end
seat:FindFirstChild("Right Arm").BrickColor = BrickColor.new(rac)
seat:FindFirstChild("Left Arm").BrickColor = BrickColor.new(lac)
seat:FindFirstChild("Head").BrickColor = BrickColor.new(hc)
seat:FindFirstChild("Torso").BrickColor = BrickColor.new(tc)
seat:FindFirstChild("Right Leg").BrickColor = BrickColor.new(rlc)
seat:FindFirstChild("Left Leg").BrickColor = BrickColor.new(llc)
for i,v in pairs(seat:GetChildren()) do
if v:FindFirstChild("Transparency") ~= nil then
if v.Transparency == 1 then
v.Transparency = 0
end
end
if v:FindFirstChild("Decal") ~= nil then
v.Decal.Transparency = 0
v.Decal.Image = v.Character:FindFirstChild("Head").face.Texture
end
end
player.Character:Remove() -- this is where it errors
end) |