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

Making a gui appear and disappear when you step on/off a part?

Asked by 8 years ago
Edited 8 years ago

I'm sorry that this doesn't follow guidelines, but I have no idea where to start on this script and there is literally no resource on the entire web that I could find that would help me figure this out. The title is pretty self explanatory. Although, I want to make it so that the gui doesn't appear on the block its self, but the specific player that steps on it. I just want a general idea of what might be able to do this, not the full script its self.

EDIT:

Okay, I understand what I need to do for this to happen. Although, I'm not exactly sure how to code it. How do I use TouchEnded with a function? Heres what I got so far:

local function onTouch(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then

print("Gui cloning goes here")

end

end

script.Parent.Touched:connect(onTouch)

Signal TouchEnded (
    BasePart otherPart
)

EDIT: According to one of the comments below, you do it the exact same way that you do with OnTouch. The thing is, when I tried this, the output literally got spammed with the TouchEnded message.

local function onTouch(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then

print("Gui cloning goes here")

end

end

local function TouchEnded(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then

print("Touch Has Ended")

end

end

script.Parent.Touched:connect(onTouch)

script.Parent.Touched:connect(TouchEnded)
0
TouchEnded is the same thing as Touched. Just connect it to a function. shayner32 478 — 8y
0
Shayner, I tried and it's not quite working.. Danielch1234 20 — 8y

1 answer

Log in to vote
4
Answered by
shayner32 478 Trusted Moderation Voter
8 years ago

Simple! Connect a function to the 'Touched' event of a part. Check if the part has a humanoid in it, and if it does, check if the part's parent's name is also a player. If so, then clone a GUI to their PlayerGui. Then, another function to handle the 'TouchEnded' event of a part, and do the same checks. If they are a player, then check if they have the GUI in their PlayerGui. If so, destroy it!

TL;DR Touched and TouchEnded on a part to clone / destroy GUI to/from players who step on it.

0
:D User#11440 120 — 8y
1
No need to check for the humanoid -- just use GetPlayerFromCharacter. Also, it would probably be better to make a GUI visible and invisible instead of cloning it. Perci1 4988 — 8y
0
Yea, but then if he turned FE on it wouldn't work. The cloning, I feel, is a perfect solution for beginners. User#11440 120 — 8y
0
It would still work with FE, assuming he connected Touched with a server script. Perci1 4988 — 8y
View all comments (3 more)
0
What's FE? Danielch1234 20 — 8y
0
FilteringEnabled. shayner32 478 — 8y
0
Ah. Danielch1234 20 — 8y
Ad

Answer this question