Player becomes invisible when sit down

I need a script where if a player seats on the vehicle seat, the player becomes invisible.

Any help is appreciated!

2 Likes
local WantedTransparency = 1 -- Change this to the transparency you want it to be.
script.Parent.ChildAdded:Connect(function()
	if script.Parent.Occupant then
		for i,v in pairs(script.Parent.Occupant.Parent:GetChildren()) do
			if v:IsA("BasePart") then
				if v.Name == "HumanoidRootPart" then
					-- Will ignore HumanoidRootPart
				else
					v.Transparency = WantedTransparency
				end
			elseif v:IsA("Accessory") then
				v.Handle.Transparency = WantedTransparency
			end
		end
	end
end)
7 Likes

Thank you! Works like charm! :smiley:

1 Like
  • If you want the player to be visible when left the car, you can copy this script and paste this script under the “end)”, just like this.(sorry for my bad english)

local WantedTransparency = 1 – Change this to the transparency you want it to be.
script.Parent.ChildAdded:Connect(function()
if script.Parent.Occupant then
for i,v in pairs(script.Parent.Occupant.Parent:GetChildren()) do
if v:IsA(“BasePart”) then
if v.Name == “HumanoidRootPart” then
– Will ignore HumanoidRootPart
else
v.Transparency = WantedTransparency
end
elseif v:IsA(“Accessory”) then
v.Handle.Transparency = WantedTransparency
end
end
end
end)

local WantedTransparency = 0
script.Parent.ChildRemoved:Connect(function()
if script.Parent.Occupant then
for i,v in pairs(script.Parent.Occupant.Parent:GetChildren()) do
if v:IsA(“BasePart”) then
if v.Name == “HumanoidRootPart” then
– Will ignore HumanoidRootPart
else
v.Transparency = WantedTransparency
end
elseif v:IsA(“Accessory”) then
v.Handle.Transparency = WantedTransparency
end
end
end
end)