Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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


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)

1 comment

0

The part will get touched if cancollide is set to false still so I added a toggle

2 answers

✓ Accepted answer

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.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.