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

Why won't this GUI disappear when the player steps on this brick?

Asked by 7 years ago

This script is supposed to make the "jay" GUI disappear after the player steps on a brick.

Your assistance is appreciated greatly!


function onTouched(hit)
    local guy = game.Players:GetPlayerFromCharacter(hit.Parent)
    local ha = guy.PlayerGUI:findFirstChild("jay")
    ha:Remove()
end

script.Parent.Touched:connect(onTouched)

0
Do "(hit.Parent.Parent)" its finding the body part GimmeWaffleBruh 18 — 7y

3 answers

Log in to vote
1
Answered by 7 years ago

I think you spelled "PlayerGui" incorrectly

0
Nice catch. This still wouldn't work with FE, though. OldPalHappy 1477 — 7y
Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Scripts can't see things in PlayerGui the server didn't put there if FE is enabled.

I recommend using a Local Script running on the client detecting this. You can then check if they're the one who touched the part. Here's an example:

--// Local Script in ReplicatedFirst or something

local part = workspace:WaitForChild("Part Name")
local localPlayer = game.Players.LocalPlayer

part.Touched:Connect(function(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if((plr)and(plr==localPlayer))then
        local gui = plr.PlayerGui.ScreenGui.GuiName
        gui:Destroy()
    end
end)

I used anonymous functions and, like I said, a Local Script.

Log in to vote
0
Answered by 7 years ago
function onTouched(hit)
    local guy = game.Players:GetPlayerFromCharacter(hit.Parent)
    local ha = guy.PlayerGUI:FindFirstChild("jay")
    ha:Destroy()
end

script.Parent.Touched:connect(onTouched)

Instead of using :Remove()

Try to use Destroy.

If you have any questions fee free to ask.

2
That doesn't fix the error. This just informs him on deprecation. OldPalHappy 1477 — 7y

Answer this question