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 9 years ago

local players = game:GetService("Players")

function onTouched(part)

1local player = players:GetPlayerFromCharacter(part.Parent)
2    ~~~~~~~~~~~~~~~~~
1if player then
1local abzx = player.PlayerGui.Objective1.Frame
1abzx:Destroy()
1script.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 9 years ago
1function onTouched(part)
2local player = game.Players:GetPlayerFromCharacter(part.Parent)
3if part.Parent:findFirstChild("Humanoid") then
4local abzx = player.PlayerGui.Objective1.Frame
5abzx:Destroy()
6end
7end
8script.Parent.Touched:connect(onTouched)

It should work :) I wish I helped You

0
It does not work EmperorTerminus 55 — 9y
Ad

Answer this question