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

How do I make a brick that turns on GUI?

Asked by 5 years ago
Edited 5 years ago

I'm sorry, this is probably an extremely basic question, but I use the code below with anything else and it works fine, but when i replace what it does with the GUI things, it stops working. Why does this happen?

Noobley = game.StarterGui.ScreenGui.DialogueGUI.Noobley.Text.Double
nExplain = game.StarterGui.ScreenGui.DialogueGUI.Noobley.Text.Double
Double = game.StarterGui.ScreenGui.DialogueGUI.Noobley.Portraits.nExplain
Next = game.StarterGui.ScreenGui.DialogueGUI.Next
Name = game.StarterGui.ScreenGui.DialogueGUI.Name
Text = game.StarterGui.ScreenGui.DialogueGUI.Text

function onTouched(hit)
Noobley.Visible = true --The name
nExplain.Visible = true --The portrait
Double.Visible = true --The text
Next.Visible = true --The next button
Name.Visible = true --The name box
Text.Visible = true --The text box
end 
script.Parent.Touched:connect(onTouched)

@Zenith_Lord is this how I'm supposed to do it? also should i put the part and the gui in the brick?


Text = script.Parent.Text function onTouched(hit) -- A few safety checks if hit and hit.Parent then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then Text.Parent = plr.PlayerGui -- Whatever other guis you have, parent them to the plr's PlayerGui end end end script.Parent.Touched:Connect(onTouched)
0
It's in PlayerGui not StarterGui User#19524 175 — 5y
0
He was making the StarterGui UI's Visible but not in the Player's view. cherrythetree 130 — 5y

1 answer

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

Put the guis inside the player's PlayerGui. I also indented everything properly:

--[[
 ... (guis here)
]]

function onTouched(hit)
    -- A few safety checks
    if hit and hit.Parent then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr then
            Noobley.Parent = plr.PlayerGui
            nExplain.Parent = plr.PlayerGui
            -- Whatever other guis you have, parent them to the plr's PlayerGui
        end
    end
end

script.Parent.Touched:Connect(onTouched)

Ad

Answer this question