(New to scripting)
My goal is to make a inventory and when i click the “PartButton”, a part will spawn. but, the inventory will not open.
-- Close Button Script:
local ImageButton = script.Parent
local PartButton = script.Parent.Parent.ImageButton
local InvText = script.Parent.Parent.InvText
local Frame = script.Parent.Parent.Parent.Frame
local colorNormal = Color3.new(1, 1, 1)
local colorHover = Color3.new(0.533333, 0.533333, 0.533333)
local colorPress = Color3.new(0.101961, 1, 0)
local function OnActivated()
ImageButton.ImageColor3 = colorPress
wait()
ImageButton.Active = false
ImageButton.ImageTransparency = 1
PartButton.Active = false
PartButton.ImageTransparency = 1
InvText.Transparency = 1
InvText.TextTransparency = 1
Frame.Transparency = 1
end
local function OnHover()
ImageButton.ImageColor3 = colorHover
end
local function OnLeave()
ImageButton.ImageColor3 = colorNormal
end
ImageButton.MouseEnter:Connect(OnHover)
ImageButton.MouseButton1Down:Connect(OnPress)
ImageButton.MouseButton1Up:Connect(OnLeave)
ImageButton.Activated:Connect(OnActivated)
–Backpack Open Script
local SGui = game:GetService(“StarterGui”)
local imageButton = script.Parent
local colorNormal = Color3.new(1, 1, 1)
local colorHover = Color3.new(0, 1, 0) – green
local colorPress = Color3.new(1, 0, 0) – red
local ImageButton = SGui.Inventory.Frame.Close
local PartButton = SGui.Inventory.Frame.ImageButton
local InvText = SGui.Inventory.Frame.InvText
local Frame = SGui.Inventory.Frame
local function OnActivated()
wait()
ImageButton.Active = true
ImageButton.ImageTransparency = 0
PartButton.Active = true
PartButton.ImageTransparency = 0
InvText.Transparency = 0
InvText.TextTransparency = 0
Frame.Transparency = 0
end
local function OnPressed()
imageButton.ImageColor3 = colorPress
end
local function OnReleased()
imageButton.ImageColor3 = colorHover
end
local function OnEntered()
imageButton.ImageColor3 = colorHover
end
local function OnLeft()
imageButton.ImageColor3 = colorNormal
end
imageButton.Activated:Connect(OnActivated)
imageButton.MouseEnter:Connect(OnEntered)
imageButton.MouseLeave:Connect(OnLeft)
imageButton.MouseButton1Down:Connect(OnPressed)
imageButton.MouseButton1Up:Connect(OnReleased)