Ad
Log in to vote
0

Instance.New Not Creating Frame?

Asked by 8 days ago

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)
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. ssgmalachi 37 — 8d

3 answers

Log in to vote
0
Answered by 8 days ago
Edited 8 days ago

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)
0
Thanks! NotConnorRandumb 2 — 8d
Ad
Log in to vote
0
Answered by
ads_bv 29
8 days ago

example:

local frame = instance.new("Frame")
0
Huh? NotConnorRandumb 2 — 8d
Log in to vote
0
Answered by 8 days ago

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.

Answer this question