Script that sets transparency to zero does not work

I recently created a game in which players can choose an RP avatar in the lobby game and are then teleported to the other game (the main game). One of the characters is causing me problems, however, namely the character called Ghost. This character has a body transparency of 0.75. The problem is that all other characters now also have a transparency of 0.75. I tried to write a script that if the player does not receive the teleport message: Ghost or no message in general, the body transparency is set to zero, but it doesn’t work at all. Can someone explain to me how I can write a script that works?

the script with which the player is teleported out of the lobby game

local TeleportService = game:GetService("TeleportService")

local PLACE_ID = 3763568 

local function TeleportPlayerWithMorph(Player, Morph)
	local TeleportOptions = Instance.new("TeleportOptions")

	TeleportOptions:SetTeleportData({
		["Morph"] = Morph,
	})

	TeleportService:TeleportAsync(PLACE_ID, {Player}, TeleportOptions)
end
TeleportPlayerWithMorph(Player, "Ghost")
1 Like

I’m confused, could you elaborate what you meant by this? Like when the teleport errors?

1 Like

So, the player is teleported out of the lobby game with a message (he is teleported out with the specified script, which also sends the Ghost message). Once in the main game, another script sets the transparency to 0.75 when the script receives the Ghost message. The problem here, however, is that the other players who joined the RP game with a different RP morph also assume the transparency of 0.75. I don’t know how to write a script that if a player doesn’t receive the Ghost message, the transparency is not set to 0.75 (players who don’t receive the Ghost message = transparency at 0
players who receive the Ghost message = transparency at 0.75)
I hope you were able to understand everything.

1 Like

Do you mean this:


Could we take a look at this Script as well? It may be the cause of the issue.

The Script:



			setTransparency(Character:FindFirstChild("Head"))
			setTransparency(Character:FindFirstChild("UpperTorso"))
			setTransparency(Character:FindFirstChild("LowerTorso"))
			setTransparency(Character:FindFirstChild("LeftUpperArm"))
			setTransparency(Character:FindFirstChild("LeftLowerArm"))
			setTransparency(Character:FindFirstChild("LeftHand"))
			setTransparency(Character:FindFirstChild("RightUpperArm"))
			setTransparency(Character:FindFirstChild("RightLowerArm"))
			setTransparency(Character:FindFirstChild("RightHand"))
			setTransparency(Character:FindFirstChild("LeftUpperLeg"))
			setTransparency(Character:FindFirstChild("LeftLowerLeg"))
			setTransparency(Character:FindFirstChild("LeftFoot"))
			setTransparency(Character:FindFirstChild("RightUpperLeg"))
			setTransparency(Character:FindFirstChild("RightLowerLeg"))
			setTransparency(Character:FindFirstChild("RightFoot"))
1 Like

Well. Your setting the transparency to 0.75 no matter the morph. Add an if statement to ensure the morph is “Ghost”, and if not, do another elseif check for a different morph.

1 Like

Do you mean something like this?

local InsertService = game:GetService("InsertService")
local AssetService = game:GetService("AssetService")
local Players = game:GetService("Players")


                setTransparency(Character:FindFirstChild("Head"))
                setTransparency(Character:FindFirstChild("UpperTorso"))
                setTransparency(Character:FindFirstChild("LowerTorso"))
                setTransparency(Character:FindFirstChild("LeftUpperArm"))
                setTransparency(Character:FindFirstChild("LeftLowerArm"))
                setTransparency(Character:FindFirstChild("LeftHand"))
                setTransparency(Character:FindFirstChild("RightUpperArm"))
                setTransparency(Character:FindFirstChild("RightLowerArm"))
                setTransparency(Character:FindFirstChild("RightHand"))
                setTransparency(Character:FindFirstChild("LeftUpperLeg"))
                setTransparency(Character:FindFirstChild("LeftLowerLeg"))
                setTransparency(Character:FindFirstChild("LeftFoot"))
                setTransparency(Character:FindFirstChild("RightUpperLeg"))
                setTransparency(Character:FindFirstChild("RightLowerLeg"))
                setTransparency(Character:FindFirstChild("RightFoot"))
            else
                -- Additional elseif checks for other Morphs can be added here
                if Morph == "AnotherMorph" then
                    -- Perform actions for "AnotherMorph"
                end
            end
        end
    end)
end)
1 Like

exactly. I usually put the if on the same line as else to keep it clean. That should work.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.