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

ScreenGui not showing and Sound not playing?

Asked by 7 years ago

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)
0
if FilteringEnabled on creeperhunter76 554 — 7y
0
Maybe it's because you didn't put the Frame on Local picture= p.PlayerGui.ScreenGui.(Frame).ImageLabel CyberHubbie 0 — 7y
0
Neither of these ideas are working, I wonder why it isn't working :/ Plutoeros 2 — 7y
0
Hi, "GetPlayersFromCharacter" is not a valid member of Players. Arti_BLOX 58 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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

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

Answer this question