Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a player that sits in my vehicle turn invisible?

Asked by
Xiam 10
8 years ago

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.

3 answers

Log in to vote
0
Answered by
Unlimitus 120
8 years ago

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)

0
Figured out where I messed up, it worked, thanks. Xiam 10 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
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)
0
Just checked it again -- my player isn't turning invisible for some reason. Xiam 10 — 8y
0
is the script inserted inside the seat? Yumeragon 45 — 8y
0
Yup, don't know why it's not working. Xiam 10 — 8y
Log in to vote
0
Answered by 8 years ago

This isn't an request site, please refer to the ROBLOX Wiki.

0
Oh, sorry about that. I'll make sure I avoid that in the future. Xiam 10 — 8y

Answer this question