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

Trying to learn how to use instance.new: Why wont the frame show on my screen?

Asked by
OFF_S4LE 127
4 years ago

The script in serverscriptservice:

01local Frame = Instance.new("Frame")
02local ScreenGui = Instance.new("ScreenGui")
03local StarterGui =  game.StarterGui
04ScreenGui.Parent = StarterGui
05Frame.Parent = ScreenGui
06Frame.Position "{0, 0},{0, 0}"
07Frame.Size "{0, 100},{0, 100}"
08if Frame.Visible == false then
09    Frame.Visible = true
10end
0
The frame and screen gui shows in StarterGui but not on my screen?! OFF_S4LE 127 — 4y
0
in line 3 do local StarterGui = game.Players.LocalPlayer.PlayerGui and make it in local script (i dont know if it works but you can try) IzaXD123456 21 — 4y

3 answers

Log in to vote
1
Answered by
tomekcz 174
4 years ago
Edited 4 years ago
01local Frame = Instance.new("Frame")
02local ScreenGui = Instance.new("ScreenGui")
03local PlayerGui =  game.Players.LocalPlayer.PlayerGui
04ScreenGui.Parent = PlayerGui
05Frame.Parent = ScreenGui
06Frame.Position = UDim2.new(0, 0,0, 0)
07Frame.Size = UDim2.new(0, 100,0, 100)
08if Frame.Visible == false then
09    Frame.Visible = true
10end
0
Only 1 OFF_S4LE 127 — 4y
0
is it local script or script? on who do u want it to happen player that touched some brick i dont know? tomekcz 174 — 4y
0
Its a local script in startergui I just want it to show on my screen nothing else ill add a function later OFF_S4LE 127 — 4y
0
so does it work or not tomekcz 174 — 4y
View all comments (2 more)
0
no work OFF_S4LE 127 — 4y
0
for me it works tomekcz 174 — 4y
Ad
Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago

The correct way on setting gui position is by using Udim2.new:

01local Frame = Instance.new("Frame")
02local ScreenGui = Instance.new("ScreenGui")
03local StarterGui =  game.StarterGui
04ScreenGui.Parent = StarterGui
05Frame.Parent = ScreenGui
06Frame.Position Udim2.new(0, 0,0, 0)
07Frame.Size Udim2.new(0, 100,0, 100)
08if Frame.Visible == false then
09    Frame.Visible = true
10end
0
But then Frame.Position has a red line :/ OFF_S4LE 127 — 4y
0
because he forgot the = sign sean_thecoolman 189 — 4y
Log in to vote
0
Answered by 4 years ago

Easy

1local ScreenGui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
2local Frame = Instance.new("Frame",ScreenGui)
3Frame.Position Udim2.new(0, 0,0, 0)
4Frame.Size Udim2.new(0, 100,0, 100)
5if Frame.Visible == false then
6    Frame.Visible = true
7end

Answer this question