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

My Death GUI will not show when someone dies, Why?

Asked by 7 years ago
Edited 7 years ago

Accomplishment:

I am working on a death script, I already the animations done, I have to get the GUI to show up on the screen.


Problem:

The problem is an error. I don't know why the computer can't under stand what i'm trying to say.


Error:

Workspace.KillBrick.wasted:3: attempt to index a nil value. Stack Begin Script 'Workspace.KillBrick.wasted', Line 3 Stack End


Prediction

My prediction is that I need to verify that the object that hits the brick is a player.


Script:

script.Parent.Touched:connect(function(player) -- When the brick is touched
    local gui = game.ServerStorage.Wasted:Clone() -- Cloning the gui
    gui.Parent = game.Players:GetPlayerFromCharacter(player).PlayerGui -- Error
    script.Parent.CanCollide = false - -So the GUI won't get cloned more than once.
    wait(6)
    script.Parent.CanCollide = true
    game.Players:GetPlayerFromCharacter(player).PlayerGui.Wasted.Parent =                                           game.ServerStorage
end)

0
The part will get touched if cancollide is set to false still so I added a toggle SparkleTimeGold 2 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 6 years ago

What you did was assume that what hit it was the player, what actually hit it was a body part of the player. All you need to do to fix this is put hit.Parent game.Players:GetPlayerFromCharacter(player.Parent).PlayerGui on line 3 in the parentheses.

Ad
Log in to vote
0
Answered by 7 years ago

local toggle = false

script.Parent.Touched:connect(function(player) -- When the brick is touched if toggle == false then local gui = game.ServerStorage.Wasted:Clone() -- Cloning the gui gui.Parent = game.Players:GetPlayerFromCharacter(player.Parent).PlayerGui -- Error toggle = true wait(6) game.Players:GetPlayerFromCharacter(player).PlayerGui.Wasted.Parent = game.ServerStorage
wait(6) toggle = false end end)

Answer this question