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:

local Frame = Instance.new("Frame")
local ScreenGui = Instance.new("ScreenGui")
local StarterGui =  game.StarterGui
ScreenGui.Parent = StarterGui
Frame.Parent = ScreenGui
Frame.Position "{0, 0},{0, 0}"
Frame.Size "{0, 100},{0, 100}"
if Frame.Visible == false then
    Frame.Visible = true
end
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
local Frame = Instance.new("Frame")
local ScreenGui = Instance.new("ScreenGui")
local PlayerGui =  game.Players.LocalPlayer.PlayerGui
ScreenGui.Parent = PlayerGui
Frame.Parent = ScreenGui
Frame.Position = UDim2.new(0, 0,0, 0)
Frame.Size = UDim2.new(0, 100,0, 100)
if Frame.Visible == false then
    Frame.Visible = true
end


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:

local Frame = Instance.new("Frame")
local ScreenGui = Instance.new("ScreenGui")
local StarterGui =  game.StarterGui
ScreenGui.Parent = StarterGui
Frame.Parent = ScreenGui
Frame.Position Udim2.new(0, 0,0, 0)
Frame.Size Udim2.new(0, 100,0, 100)
if Frame.Visible == false then
    Frame.Visible = true
end
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

local ScreenGui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
local Frame = Instance.new("Frame",ScreenGui)
Frame.Position Udim2.new(0, 0,0, 0)
Frame.Size Udim2.new(0, 100,0, 100)
if Frame.Visible == false then
    Frame.Visible = true
end

Answer this question