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

What Is Wrong With My Piece Of Code?

Asked by 10 years ago

I'm trying to get a GUI placed in the toucher of a seat when they sit down, however it's turned out rather crooked.

GUI = script.Parent.GOLIATH

script.Parent.Touched:connect(function (hit)
    wait(0.5)
    if not script.Parent:FindFirstChild("SeatWeld") then return end
        if not game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.GOLIATH then
            local NewGUI = GUI:Clone()
            NewGUI.Parent = game.Players:FindFirstChild(hit.Parent.Name).PlayerGui
    end
end)

That's the code, and it's throwing the error: GOLIATH is not a valid member of PlayerGui Script 'Workspace.Goliath Prototype, dawg.Part.Script', Line 6 Stack End

The objective of the script is to check if the player has the GUI, and if not, place the GUI on their screen. When they stop touching the seat, the GUI disappears.

1 answer

Log in to vote
0
Answered by 10 years ago

Try this if game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.GOLIATH ~= nil then

Ad

Answer this question