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

How do i display a gui if a player touched something?

Asked by
CjayPlyz 643 Moderation Voter
6 years ago

if a player touches a specific wall it will load the character and display the gui, but i don't know how to make a gui show up if a player touched something, do i use getplayerfromcharacter then playergui?

2 answers

Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

You could use a RemoteEvent for this, and when a player touches the wall then fire the remote to the client who touched it, but I would just use a LocalScript.

You can make a LocalScript in the gui that you want to make appear, and reference the wall that needs to be touched:

local gui = script.Parent
local wall = workspace:WaitForChild("touchWall") -- reference the wall 
local player = game.Players.LocalPlayer

wall.Touched:connect(function(touchedPart)
    if touchedPart.Parent == player.Character then
        gui.Enabled = true
    end
end)
0
thanks CjayPlyz 643 — 6y
0
by the way its "Enabled" not "Visible" lel, and you forgot to put "end" on line 9 ;) CjayPlyz 643 — 6y
0
but its fine CjayPlyz 643 — 6y
0
oops haha, sorry, it was a fairly quick make chomboghai 2044 — 6y
Ad
Log in to vote
1
Answered by
oreoollie 649 Moderation Voter
6 years ago
Edited 6 years ago

Yea. That's pretty much exactly what you need to do. The script that will do it is below.

local gui = Path.To.Gui 

function CloneGui(p)
    if p.Parent:FindFirstChildOfClass("Humanoid") then
        local clone = gui:Clone()
        clone.Parent = game.Players:GetPlayerFromCharacter(p.Parent).PlayerGui
    end
end

workspace.Part.Touched:Connect(CloneGui)

I hope my answer solved your problem! If it did, don't forget to mark it as correct!

Answer this question