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

How do I make a gui open when touching a part?

I want the GUI to slowly fade in when the player touches the part. Ive got the gui and the Local Script done but it doesnt work

function onTouched(hit)
	game.StarterGui.Route1.MainFrame.BackgroundTransparency = 0.1
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.9
	wait(0.02)
	game.StarterGui.Route1.MainFrame.BackgroundTransparency = 0.2
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.8
	wait(0.02)
	game.StarterGui.Route1.MainFrame.BackgroundTransparency = 0.3
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.7
	wait(0.02)
	game.StarterGui.Route1.MainFrame.BackgroundTransparency = 0.4
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.6
	wait(0.02)
	game.StarterGui.Route1.MainFrame.BackgroundTransparency = 0.5
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.5
	wait(0.02)
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.4
	wait(0.02)
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.3
	wait(0.02)
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.2
	wait(0.02)
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0.1
	wait(0.02)
	game.StarterGui.Route1.MainFrame.TextLabel.TextTransparency = 0
	wait(0.02)
end

script.Parent.Touched:connect(onTouched)

PLEASE HELP!

1 answer

Try this. (Apologies for the script writing, it's 12 AM.) It works.

local gui = script.Parent.Gui --Put the Gui in the part the player will touch.
script.Parent.Touched:connect(function (hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players[hit.Parent.Name]
if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(gui.Name) then
gui.Parent = plr.PlayerGui
for i = 1,100 do
gui.Frame.BackgroundTransparency = gui.Frame.BackgroundTransparency - 0.01
wait()
end
end
end
end)

Make sure to put the Gui you want to appear inside of the part.

1 comment

0

Didnt work when I tried it.

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