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

How do i Enable ScreenGuis using a Script (local or server)?

Asked by 2 years ago
Edited 2 years ago

Basically it's a bit like my other question but forget that.

So i inserted a ScreenGui into StarterGui which will end up in PlayerGui when testing. Inside that ScreenGui, I inserted a Frame, and inside that frame, a LocalScript and Textlabel, and what i want to do, is make it so if "Script 1" (which is a ServerScript in Workspace) activate the ScreenGui (and maybe the LocalScript also)

Script 1:

function onClick()
    game.Workspace.Eggs.Egg1.Transparency = 1
    game.Workspace.Eggs.Egg1.CanCollide = false
    game.Workspace.Eggs.Egg1.CanTouch = false
    game.Workspace.Eggs.Egg1.egg: Play()
end

script.Parent.MouseClick:Connect(onClick)

LocalScript inside of PlayerGui:

local textLabel = script.Parent:WaitForChild("TextLabel")

wait(3)

local function typewrite(object,text, length)
    for i = 1,#text,1 do
        object.Text = string.sub(text,1,i)
        wait(length)
    end
end

typewrite(textLabel, "Looks like you found an egg...", 0.0005)
wait(2)
typewrite(textLabel, "A reward might follow if you find all the other eggs...", 0.0005)
wait(2)

My Explorer tab: https://i.gyazo.com/3c24fbaf8560e9dd99e36e0a36f76241.png (don't mind the deactivated script it's activated this post was edited)

1 answer

Log in to vote
2
Answered by
Jac_00b 157
2 years ago

For a localscript, all you have to is just use PlayerGui from the LocalPlayer. Example:

local player = game.Players.LocalPlayer
player.PlayerGui.Example.Enabled = true

For a serverscript, you will have to use a RemoteEvent to get the player that you want the Gui to show up on. Example:

game.ReplicatedStorage.Example.OnServerEvent:Connect(function(player)
player.PlayerGui.Example.Enabled = true

Hope this helped.

Ad

Answer this question