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

Touching Brick Opening A GUI Script?

Asked by 9 years ago

I can't seem to script a brick that, when touched, opens a GUI. Can someone answer a script that does that? Thanks!

2 answers

Log in to vote
0
Answered by 9 years ago
game.StarterGui(I assume it's here).(NameOfGUI).Visible = true

function DemNips()
game.StarterGui(I assume it's here).(NameOfGUI).Visible = true
end

script.Parent.Touched:connect(DemNips()

function DemNipsMarkII()
if game.StarterGui(I assume it's here).(NameOfGUI).Visible == true then
game.StarterGui(I assume it's here).(NameOfGUI).Visible = false
end

script.Parent.TouchEnd:connect(DemNipsMarkII()

Should work. Enjoy my creative naming. Generally though, don't ask an entire script to be written for you

0
Thanks @Wolf PikachuShockwave 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
local Gui = game.ServerStorage.TheScreenGui-- Replace this with location of the GUI
local Trigger = script.Parent -- Replace this with location of the part that opens the GUI
local Debounce = false --See http://wiki.roblox.com/index.php?title=Debounce

local function Touched(Part)
    if Debounce then return end
    local Player = game.Players:GetPlayerFromCharacter(Part.Parent) --Gets the player from the character model
    if Player then --If it exists
        Debounce = true
        Gui:Clone().Parent = Player.PlayerGui --Clone the GUI into PlayerGui, where active GUIs are held
        wait()
        Debounce = false
    end
end

Trigger.Touched:connect(Touched)

Note that this may not fit your use case exactly. It gives them a GUI even if they already have it; this may or may not be what you want. I'll leave that as homework though. Excuse any typos I may have made.

Answer this question