I want to make it so when you pick up a battery it changes the color of the battery icon that can be seen on the screen showing how many batteries are left.
The problem is that I always manage to mess up the most simple of scripts. The battery gets destroyed as intended it plays the pick up sound but it just refuses to change the color of the image button.
This is the script:
local Battery = script.Parent
local Icon = game.StarterGui.BatteryHUD.Frame.B1
local Click = Battery.ClickDetector
local Sound = script.Parent.Pickup
Click.MouseClick:Connect(function()
Icon.ImageColor3 = Color3.fromRGB(255, 255, 255)
Sound:Play()
Battery:Destroy()
end)
I tried to make the script also make the icon invisible to see if the script refuses to work with the GUI and it didn’t.
As always there were no threads on devforum about it and no errors in the output.