slinky22
(Slinky)
July 6, 2019, 5:08pm
#1
So i want the GUI to appear straight away after the player has leveled up instead of respawn, but idk how to do this
local screengui = Instance.new("ScreenGui",game:GetService("StarterGui"))
local frame = Instance.new("Frame",screengui)
screengui.Parent = game.StarterGui
screengui.Name = "ExampleGUI"
screengui.Enabled = true
frame.Name = "ExampleFrame"
frame.Size = UDim2.new(0.5,0,0.5,0)
frame.Position = UDim2.new(0.25,0,0.25,0)
wait(3)
screengui.Enabled = false
2 Likes
xLawOut
(xLawOut)
July 6, 2019, 5:16pm
#2
In
local screengui = Instance.new("ScreenGui",game:GetService("StarterGui"))
, instead of doing game:GetService("StarterGui")
, do game.Players.LocalPlayer.PlayerGui
.
The reason for this is because StarterGui is the thing that replicates to clients when they join the game/respawn, but playergui is the thing that is actively showing everything in it.
slinky22
(Slinky)
July 6, 2019, 5:29pm
#3
local screengui = Instance.new(“ScreenGui”,game.Players.LocalPlayer.PlayerGui)
like this right, i tried and it does not work.
1 Like
xLawOut
(xLawOut)
July 6, 2019, 5:31pm
#4
Is this a local script or a server script?
Edit: Nevermind, I see the problem.
local screengui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui) -- You are setting the parent to playergui.
local frame = Instance.new("Frame",screengui)
screengui.Parent = game.StarterGui -- Then you're setting the parent to StarterGui.
screengui.Name = "ExampleGUI"
screengui.Enabled = true
frame.Name = "ExampleFrame"
frame.Size = UDim2.new(0.5,0,0.5,0)
frame.Position = UDim2.new(0.25,0,0.25,0)
wait(3)
screengui.Enabled = false
So simply remove this line: screengui.Parent = game.StarterGui
, and it will work.
1 Like
slinky22
(Slinky)
July 6, 2019, 5:45pm
#5
its in a server script, i get the error attempet to index field localplayer (a nil value)
xLawOut
(xLawOut)
July 6, 2019, 5:47pm
#6
UI design should be generally made and controlled by the client. Put the code in a local script and it will work.
If you need the GUI to appear during specific moments (like levelling up), you need to use remote events . You can read about them here: RemoteEvent | Documentation - Roblox Creator Hub
slinky22
(Slinky)
July 6, 2019, 5:51pm
#8
How would i do this?, i am not using a click gui or button so i cant use Mouseclick1 and i dont know what to put.
local screengui = Instance.new("ScreenGui", game.Players.PLAYERNAME.PlayerGui)
local frame = Instance.new("Frame",screengui)
screengui.Name = "ExampleGUI"
screengui.Enabled = true
frame.Name = "ExampleFrame"
frame.Size = UDim2.new(0.5,0,0.5,0)
frame.Position = UDim2.new(0.25,0,0.25,0)
wait(3)
screengui.Enabled = false
This should work.
4 Likes
HmmBilly
(BillyH)
July 6, 2019, 5:55pm
#10
why would you disable it after 3 Seconds?
slinky22
(Slinky)
July 6, 2019, 5:57pm
#11
So it goes away, but i changed that to destroy instead.
HmmBilly
(BillyH)
July 6, 2019, 5:58pm
#12
Oops, Didn’t read it fully, my bad.