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

ScreenGui not showing and Sound not playing?

I asked this question on the forums, but I got little to no help on the issue, so I thought I'd try here for help (and I was also told the ROBLOX Scripters forum is a little toxic).

So basically, when the player touches a brick (or in this case the UpperTorso of an R15 AI NPC) the brick kills them (which I have down) but the problem arises when the player dies, a ScreenGUI and a sound (which loops and is already configured in the sound) is supposed to play. But for some reason it doesn't show up or play any sound whatsoever. I hope someone can understand this issue lol. Thanks in advance for anyone who helps :D

local sound = script.ScreenGui.Sound
local picture = script.ScreenGui.ImageLabel

function onTouched(hitted)
local human = hitted.Parent:findFirstChild("Humanoid")
if human.Health == 0 then
local p = game.Players:GetPlayersFromCharacter(hitted)
local sound = p.PlayerGui.ScreenGui.Sound
local picture = p.PlayerGui.ScreenGui.ImageLabel
picture.Visible = true
sound:Play()
wait(8)
picture.Visible = false
sound:Stop()
end
end

script.Parent.Touched:connect(onTouched)

4 comments

0

if FilteringEnabled on

0

Maybe it's because you didn't put the Frame on Local picture= p.PlayerGui.ScreenGui.(Frame).ImageLabel

0

Neither of these ideas are working, I wonder why it isn't working :/

0

Hi, "GetPlayersFromCharacter" is not a valid member of Players.

1 answer

"hitted" is the part that touched the brick. so to access the character just do hitted.Parent

local p = game.Players:GetPlayersFromCharacter(hitted.Parent)

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