I'm fairly new to Lua and need help with a vehicle script. I'm trying to turn the player that sits in my vehicle turn completely invisible.
✓ ANSWER ACCEPTED
How do I make a player that sits in my vehicle turn invisible?
3 answers
✓ Accepted answer
Place this in the seat or change the self variable to the path of the seat:
--[[ Unlimitus ]]--
-- Vehicle Seat Transparency Script --
local character = nil
local self = script.Parent
local debounce = false
function Touched (hit)
if debounce == false then
if character == nil then -- Prevents more than one player being affected by this function
if hit.Parent:findFirstChild("Humanoid") then
character = hit.Parent
wait(0.1) -- Wait for the character to sit
if character ~= nil then
if character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
for _, child in pairs(character:GetChildren()) do
if child:IsA("Accoutrement") then
child = child.Handle
end
if child:IsA("BasePart") then -- BasePart is a class that all "Parts" fall under
if child.Name ~= "HumanoidRootPart" then -- This is a brick not meant for view
child.Transparency = 1
end
end
end
local function HumanoidJumped()
if character ~= nil then
if character.Humanoid.Jump == true then
for _, child in pairs(character:GetChildren()) do
if child:IsA("Accoutrement") then
child = child.Handle
end
if child:IsA("BasePart") then
if child.Name ~= "HumanoidRootPart" then
child.Transparency = 0
end
end
end
if debounce == false then
debounce = true
character.Torso.CFrame = self.CFrame * CFrame.new(0, 1 + self.Size.Y / 2, -3)
character = nil
wait(1)
debounce = false
end
end
end
end
character.Humanoid.Changed:connect(HumanoidJumped)
end
end
end
end
end
end
self.Touched:connect(Touched)
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
_G.Character = hit.Parent
hit.Parent["Left Leg"].Transparency = 1
hit.Parent["Right Leg"].Transparency = 1
hit.Parent.Torso.Transparency = 1
hit.Parent["Right Arm"].Transparency = 1
hit.Parent["Left Arm"].Transparency = 1
hit.Parent.Head.Transparency = 1
end
end)
script.Parent.TouchEnded:connect(function(left)
_G.Character["Left Leg"].Transparency = 0
_G.Character["Right Leg"].Transparency = 0
_G.Character.Torso.Transparency = 0
_G.Character["Right Arm"].Transparency = 0
_G.Character["Left Arm"].Transparency = 0
_G.Character.Head.Transparency = 0
end)
3 comments
0
Just checked it again -- my player isn't turning invisible for some reason.
0
is the script inserted inside the seat?
0
Yup, don't know why it's not working.
This isn't an request site, please refer to the ROBLOX Wiki.
1 comment
0
Oh, sorry about that. I'll make sure I avoid that in the future.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Figured out where I messed up, it worked, thanks.