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

Why is this piece of code in relation to a GUI not working?

Asked by 8 years ago

local players = game:GetService("Players")


function onTouched(part)


local player = players:GetPlayerFromCharacter(part.Parent)
    ~~~~~~~~~~~~~~~~~

if player then

local abzx = player.PlayerGui.Objective1.Frame

abzx:Destroy()

end

end


script.Parent.Touched:connect(onTouched)

~~~~~~~~~~~~~~~~~

The intended purpose of this piece of code is to remove a GUI once a brick has been touched, I know there are some codes which allow me to do this but I want to understand the concept before utilizing it. I have checked the error log and nothing shows up in relevance to this script. Can anyone help me?

1 answer

Log in to vote
0
Answered by 8 years ago
function onTouched(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if part.Parent:findFirstChild("Humanoid") then
local abzx = player.PlayerGui.Objective1.Frame
abzx:Destroy()
end
end
script.Parent.Touched:connect(onTouched)

It should work :) I wish I helped You

0
It does not work EmperorTerminus 55 — 8y
Ad

Answer this question