Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

The frame and screen gui shows in StarterGui but not on my screen?!

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)

3 answers

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


6 comments

0

Only 1

0

is it local script or script? on who do u want it to happen player that touched some brick i dont know?

0

Its a local script in startergui I just want it to show on my screen nothing else ill add a function later

0

so does it work or not

0

no work

0

for me it works

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

2 comments

0

But then Frame.Position has a red line :/

0

because he forgot the = sign

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

This discussion is preserved as it was. New answers, comments, and votes are closed.