Tween Player Model Transparency

Im trying to make a script where if i player jumps into a barrel hey becomes transparent and when he jumps out he no more becomes transparent

it’s as simple as using GetDescendants() and checking if the descendant of a player is a base part, if it’s a base part it would set (or tween) the transparency of the player to 1

GetDescendants I dont know how to use it :rofl:

Have a look at this: Instance:GetDescendants (roblox.com)

local Model = ur model

for i,v in pairs(Model:GetDescendants()) do
      if v:IsA("Part") or v:IsA("MeshPart") then
            local TweenTime = 1
           local info = TweenInfo.new(TweenTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
            local goals = {Transparency = 1}
             local tween = game:GetService("TweenService"):Create(v,info,goals)
              tween:Play()
    end
end

local barrel = game.Workspace.Part --change this value
local numberdelay = 1 --time taken to tween the transparency
barrel.CanCollide = false
barrel.Anchored = true

local seat = Instance.new("Seat")
seat.Position = barrel.CFrame.Position - Vector3.new(0,barrel.Size.Y/2,0)
seat.Parent = game.Workspace
seat.Transparency = 1
local previousplayer = {}
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant ~= nil then
		local desc = seat.Occupant.Parent:GetDescendants()
		for count = 1,#desc do
			if desc[count]:IsA("BasePart") or desc[count]:IsA("MeshPart") then
				if desc[count].Transparency == 0 then
					tween:Create(desc[count],TweenInfo.new(numberdelay),{Transparency = 1}):Play()
				table.insert(previousplayer,desc[count])
				end
			end
		end
	else
		for count = 1,#previousplayer do
			tween:Create(previousplayer[count],TweenInfo.new(numberdelay),{Transparency = 0}):Play()
		end
	end
end)

here you go! this works dope!

just change the value of the barrel.

2 Likes
local function TurnTransparent(playerModel)

    

    for _,obj in pairs(playerModel:GetDescendants()) do

        if obj:IsA("BasePart") then

coroutine.resume(coroutine.create(function()

    for transparency = 0,1,0.1 do

        obj.Transparency = transparency

        wait(0.01)

    end

    

end))

        end

    end 

end

This will just turn the player invisible (hopefully), I’m doing school rn so I can help you figure out how to detect when they’re in the barrel

1 Like

This does work but the HumanoidRootPart Becomes Visible