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

I need some help with fading away players on death?

Asked by 10 years ago

function onDeath()

local game.Workspace.plr.visibility = 0.1

local game.Workspace.plr.visibility = 0.2

local game.Workspace.plr.visibility = 0.3

local game.Workspace.plr.visibility = 0.4

local game.Workspace.plr.visibility = 0.5

local game.Workspace.plr.visibility = 0.6

local game.Workspace.plr.visibility = 0.7

local game.Workspace.plr.visibility = 0.8

local game.Workspace.plr.visibility = 0.9

local game.Workspace.plr.visibility = 1

end

what i'm trying to do is when a player dies i want the player to fade away and disappear kind of like a ghost... but it doesn't seem to be working that way... can u help me please?

1 answer

Log in to vote
2
Answered by
RoboFrog 400 Moderation Voter
10 years ago

There's quite a few flaws here. Let's start at the beginning --

Your function/event isn't right at all. Take a look at the Died event page to see how to properly use it.

Second, what is "plr" supposed to be? You haven't defined it, and it has no default function. If this is in a local script, you could use game.Players.LocalPlayer.Character to reference the player. If it isn't in a local script, you should first load the Died function into a PlayerAdded function. Then, make the return from the PlayerAdded into something like "Player" which will then reference game.Players.ReturnGoesHere.Character.

Third, "Visibility" isn't anything. I think you're thinking of Transparency. Even then, the player's character doesn't have a transparency, only the body parts. You should instead be referencing each of the body parts instead of the player as a whole.

Fourth, your use of local isn't really doing anything. Only use local with variables and functions to speed up operations.

Fifth, your repetition is inefficient. Use a loop instead. An example is here -

local number = 0 

for i = 1,10 do -- do this loop 10 times
    number = number + 1
end

-- number is now equal to 10

If you have any other questions, feel free to ask.

0
Changing the 'number' variable is not needed, just use 'i'. Perci1 4988 — 10y
Ad

Answer this question