Frame color with buttons

Im have 3D glasses tool when i equipped his show frame on player screen.

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    When i click on buttons, the frame color is change to certain color. For example - blue and frame must stay in this color
  2. What is the issue? Include screenshots / videos if possible!
    When I unequipp glasses frame will change back to white color.
  3. What solutions have you tried so far?
    Currently no Idk honestly how make this. But here some code
    When player equip glasses
local Ui = script:WaitForChild("Screen")

script.Parent.Equipped:Connect(function()
	local ScreenGui = Ui:Clone()
	ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui
end)

script.Parent.Unequipped:Connect(function()
	game.Players.LocalPlayer.PlayerGui:FindFirstChild(Ui.Name):Destroy()
end)

Script that change frame color

local frame = script.Parent.Parent.Parent.Frame

script.Parent.MouseButton1Click:Connect(function()

frame.BackgroundColor3 = Color3.new(0, 0, 255)

end)

source

1 Like

I dont know what’s really the issue, but did you tried to turn off the ResetOnSpawn? I think that’s because of it.

no doesnt help
still not.wmv (364.7 KB)

I don’t know if you already know this, but when you clone the UI into the PlayerGui, any changes made to the cloned gui won’t stay because you destroy it when you unequip it.

Instead of cloning the gui every time, you could either:

  1. Have the “Screen” ScreenGui stay in the PlayerGui and set it’s Enabled property to true every time you equip/unequip the tool, using the LocalPlayer (this is recommended)
  2. Parent the “Screen” under the PlayerGui every time they equip the tool and parent the screen back under the tool when they unequip it (using the LocalPlayer).

Both of these options keep the original “Screen” so every time you equip it again, any changes made to the ScreenGui will stay.

I hope this helps!

Use Color3.fromRGB instead of Color3.new, hope this fixes your problem. :slightly_smiling_face:

You can also make the “Screen” ScreenGui be in StarterGui (I cant access rn my computer so I think that’s the name of the service) and show the gui when the tool will be equipped.

I think that should work too…?

Yeah, putting anything in the StarterGui will be in the PlayerGui when you test play the game, that’s what I meant in the first option.

1 Like

Thank you so much its working!

1 Like