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

Instance.New Not Creating Frame?

I created a chunk of code that is meant to create a frame.

Line 42 - 46

Please Help Me Fix This.

local MainMenu = script.Parent
local PlayButton = MainMenu.Buttons:WaitForChild("PlayButton")
local SettingsButton = MainMenu.Buttons:WaitForChild("SettingsButton")
local UpdateButton = MainMenu.Buttons:WaitForChild("UpdateButton")
local Player = game.Players.LocalPlayer

-- UI Hover

-- Player Button

PlayButton.MouseEnter:Connect(function()
	PlayButton.TextColor3 = Color3.new(0.133333, 0.133333, 0.133333)
end)

PlayButton.MouseLeave:Connect(function()
	PlayButton.TextColor3 = Color3.new(0,0,0)
end)

-- Settings Button

SettingsButton.MouseEnter:Connect(function()
	SettingsButton.TextColor3 = Color3.new(0.133333, 0.133333, 0.133333)
end)

SettingsButton.MouseLeave:Connect(function()
	SettingsButton.TextColor3 = Color3.new(0, 0, 0)
end)

-- Update Button

UpdateButton.MouseEnter:Connect(function()
	UpdateButton.TextColor3 = Color3.new(0.133333, 0.133333, 0.133333)
end)

UpdateButton.MouseLeave:Connect(function()
	UpdateButton.TextColor3 = Color3.new(0, 0, 0)
end)

-- Main Scripting

PlayButton.MouseButton1Click:Connect(function()
	local FadeInEffect = Instance.new("Frame")
	FadeInEffect.Name = "FadeInFrame"
	FadeInEffect.BackgroundColor3 = Color3.new(0.133333, 0.133333, 0.133333)
	FadeInEffect.Parent = MainMenu	
end)

1 comment

0

I suggest just making a frame through starterGui, but if you insist on doing it this way, make sure you put this into a local script.

3 answers

✓ Accepted answer

The frame was created, but since you didn't supply enough properties; the frame was not seen. It's there, but you just need to be able to see it. Therefore; we apply more properties to it.

--[==[
	You should always be using a ServiceProvider.
	Both the DataModel & the ServiceProvider service work.
	
	Never index a service from the DataModel, if anything can change the names of these services, indexing will break immediently.
	That is why we have ServiceProvider:GetService
]==]

-- How to get the ServiceProvider class. game does work too.
local ServiceProvider = game:GetService("ServiceProvider")

local MainMenu = script.Parent
local Buttons = MainMenu:WaitForChild("Buttons")
local PlayButton = Buttons:WaitForChild("PlayButton")
local SettingsButton = Buttons:WaitForChild("SettingsButton")
local UpdateButton = Buttons:WaitForChild("UpdateButton")

local Player = game:GetService("Players").LocalPlayer

-- UI Hover

-- Player Button

PlayButton.MouseEnter:Connect(function()
	PlayButton.TextColor3 = Color3.fromRGB(34, 34, 34)
end)

PlayButton.MouseLeave:Connect(function()
	PlayButton.TextColor3 = Color3.fromRGB(0, 0, 0)
end)

-- Settings Button

SettingsButton.MouseEnter:Connect(function()
	SettingsButton.TextColor3 = Color3.fromRGB(34, 34, 34)
end)

SettingsButton.MouseLeave:Connect(function()
	SettingsButton.TextColor3 = Color3.fromRGB(0, 0, 0)
end)

-- Update Button

UpdateButton.MouseEnter:Connect(function()
	UpdateButton.TextColor3 = Color3.fromRGB(34, 34, 34)
end)

UpdateButton.MouseLeave:Connect(function()
	UpdateButton.TextColor3 = Color3.fromRGB(0, 0, 0)
end)

-- Main Scripting

PlayButton.MouseButton1Click:Connect(function()
	local FadeInEffect = Instance.new("Frame")
	FadeInEffect.Name = "FadeInEffect"
	FadeInEffect.BackgroundColor3 = Color3.fromRGB(64, 64, 64)
	FadeInEffect.BorderMode = Enum.BorderMode.Outline
	FadeInEffect.BorderSizePixel = 0
	FadeInEffect.Size = UDim2.new(1.5, 0, 1.5, 0)
	FadeInEffect.Position = UDim2.new(0, 0, 0, 0)
	FadeInEffect.AnchorPoint = Vector2.new(0.5, 0.5)
	FadeInEffect.Visible = true
	FadeInEffect.Parent = MainMenu
end)

1 comment

0

Thanks!

You can create the frame you want in StarterGui and make it transparent. When the player clicks the play button, just change the transparency to 1 or if you want to make a smooth transition, just use TweenService.

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