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

Why wont the ScreenGui show up? I’m new to scripting so this is hard for me

Asked by 4 years ago
local Activate  = script.Parent

script.Parent.Touched:Connect(function(hit) then
        ScreenGui.Enabled = true
    end
0
its in a part called Activate. Configuator 158 — 4y

4 answers

Log in to vote
0
Answered by 4 years ago

You dont need to enable/disable screengui.You can make the childs of it visible/invisible.

0
I agree lol but I dont think thats the problem I think that the Screen Gui isnt in PlayerGui. jgftr7 74 — 4y
Ad
Log in to vote
0
Answered by
jgftr7 74
4 years ago
Edited 4 years ago

If you don't mind make sure to put parts and objects into game.workspace also here is a simple script

local part = game.workspace.part -- put part name here make sure it is a Part not model

part.Touched:Connect(function()
    ScreenGui.Enabled = true
end)

if this doesn't work then tell me the error you get!

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

Considering your code provided, there are multiple issues.

  1. script.Parent.Touched:Connect(function(hit) then, I don’t see why you have a then here when this isn’t an if statement.

  2. ScreenGui is not defined.

  3. You’re firing .Touched for every object that touches it, meaning your studio could crash due to every object in your game touching it

  4. Since I assume this is a local script (you should always use them for UI manipulation), they won’t work in the workspace, it’s best that you use a Script to detect .Touched and a remote event to a Local Script to turn on your GUI

Hope this answers your question

0
wait there was a then statement lol! jgftr7 74 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Guis are typically LocalScripts because they immediately replicate (if using StarterGui) to the LocalPlayer.PlayerGui. BasePart.Touched is an event that is typically used on Server Scripts. If you want to make the Gui visible, then use a Remote Event which fires to the client.

--//Server Script\\--

local part = script.Parent --I'm assuming the child of the part is the script
part.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then --Use this to find a player.
        game.ReplicatedStorage.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
    end
end)

So I just immediately fired a client to the player. Now I need to get it.

--//Local Script\\--

local remoteEvent = game.ReplicatedStorage.RemoteEvent
remoteEvent.OnClientEvent:Connect(function()
    script.Parent.TextLabel.Visible = not script.Parent.TextLabel.Visible --if true then false and vice versa
end)

This is the basic way to get a Pop-up Gui. You can experiment more and even improve on the script I have, but this is the most basic method. (Note: This does not account for debounce or anything like that, it's just a basic script.) Sources: AlvinBlox OpenGuiWithPart Remote Events and Functions OnClientEvent

Answer this question