Hey,
For some reason, when I clone the car that has tagged seats, the cloned car will not work. I am not sure what I am doing wrong, and if you can help me that would be great.
(Sorry for no video, Gyazo wont work…)
Server code:
local CollectionService = game:GetService("CollectionService")
local Seats_Tag = "Seats"
local SeatsT = CollectionService:GetTagged(Seats_Tag)
CollectionService:GetInstanceAddedSignal(Seats_Tag):Connect(function(Seat)
table.insert(SeatsT, Seat)
end)
CollectionService:GetInstanceRemovedSignal(Seats_Tag):Connect(function(Seat)
SeatsT = CollectionService:GetTagged(Seats_Tag)
end)
local function RemoveAccessorys(Player)
for _, BaseParts in pairs(Player.Character:GetChildren()) do
if BaseParts:IsA("Accessory") then
BaseParts.Handle.Transparency = 1
elseif BaseParts:IsA("BasePart") then
BaseParts.Transparency = 1
BaseParts.CanCollide = false
end
end
end
local function AddAccessorys(Player)
for _, BaseParts in pairs(Player.Character:GetChildren()) do
if BaseParts:IsA("Accessory") then
BaseParts.Handle.Transparency = 0
elseif BaseParts:IsA("BasePart") and BaseParts.Name ~= "HumanoidRootPart" then
BaseParts.CanCollide = true
BaseParts.Transparency = 0
end
end
end
local function SitPlayerInSeat(Seats)
Seats.Part.ProximityPrompt.Triggered:Connect(function(Player)
if Seats.Occupant then return end
if Player then
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid then
Seats:Sit(Humanoid)
Seats.Part.ProximityPrompt.Enabled = false
RemoveAccessorys(Player)
local SeatConnection
SeatConnection = Seats:GetPropertyChangedSignal("Occupant"):Connect(function()
Seats.Part.ProximityPrompt.Enabled = true
wait(0.1)
if Seats.Name == "FR" or Seats.Name == "BR" or Seats.Name == "Middle" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.RightSide.CFrame
elseif Seats.Name == "BL" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.LeftSide.CFrame
elseif Seats.Name == "DriveSeat" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.Body.LeftSide.CFrame
end
AddAccessorys(Player)
SeatConnection:Disconnect()
end)
end
end
end)
end
local function GetAllSeats()
for _, Seats in pairs(SeatsT) do
SitPlayerInSeat(Seats)
end
end
GetAllSeats()