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

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

Asked by
HjmanYT -1
6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
Didnt work when I tried it. HjmanYT -1 — 6y
Ad

Answer this question