Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

4 comments

0

thanks

0

by the way its "Enabled" not "Visible" lel, and you forgot to put "end" on line 9 ;)

0

but its fine

0

oops haha, sorry, it was a fairly quick make

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.