I have this script that controls the players’ inventory gui. It is supposed to change the color of certain items but it doesn’t. I’ve changed this script so many times so if it looks confusing or you don’t understand what a certain instance is or what it contains just ask and I’ll explain. Here is the script:
local function changecolors()
local plr = game.Players.LocalPlayer
local inventoryfolder = plr:WaitForChild("Inventory")
local particles = inventoryfolder:GetChildren()
local inv = plr.PlayerGui.ScreenGui.Inventory
local template = inv.Template
for i, v in pairs(inventoryfolder:GetChildren()) do
if inv:FindFirstChild(v.Name) == nil then
local newtemplate = template:Clone()
newtemplate.Name = v.Name
newtemplate.ImageButton.Image = v.Value
newtemplate.ItemName.Text = v.Name
if newtemplate.Name == "Blue" then
print(newtemplate.Name.." changed to blue")
newtemplate.ImageButton.ImageColor3 = Color3.new(0.3,0.5,1)
elseif newtemplate.Name == "Red" then
print(newtemplate.Name.." changed to red")
newtemplate.ImageButton.ImageColor3 = Color3.new(0.8,0,0)
elseif newtemplate.Name == "Pink" then
print(newtemplate.Name.." changed to pink")
newtemplate.ImageButton.ImageColor3 = Color3.new(1,0.7,1)
elseif newtemplate.Name == "Void" then
print(newtemplate.Name.." changed to black")
newtemplate.ImageButton.ImageColor3 = Color3.new(0,0,0)
elseif newtemplate.Name == "USA Fireworks" then
local colors = {Color3.new(1,0,0), Color3.new(1,1,1), Color3.new(0,0.15,1)}
while true do
for i, v in pairs(colors) do
newtemplate.ImageButton.ImageColor3 = v
print("Color changed")
wait(.5)
end
end
end
newtemplate.Visible = true
newtemplate.Parent = inv
print(newtemplate.Name)
else
--Still working on this ignore lol
print(v.Name.." Is in the player's inventory folder")
if v.Name == "Blue" then
print(v.Name.." changed to blue")
inv.v.ImageButton.ImageColor3 = Color3.new(0.3,0.5,1)
elseif v.Name == "Red" then
print(v.Name.." changed to red")
inv.v.ImageButton.ImageColor3 = Color3.new(0.8,0,0)
elseif v.Name == "Pink" then
print(v.Name.." changed to pink")
inv.v.ImageButton.ImageColor3 = Color3.new(1,0.7,1)
elseif v.Name == "Void" then
print(v.Name.." changed to black")
inv:FindFirstChild(v).ImageButton.ImageColor3 = Color3.new(0,0,0)
elseif v.Name == "USA Fireworks" then
local colors = {Color3.new(1,0,0), Color3.new(1,1,1), Color3.new(0,0.15,1)}
while true do
for i, thecolor in pairs(colors) do
inv.v.ImageButton.ImageColor3 = thecolor
print("Color changed")
wait(.5)
end
end
end
end
end
end
game.ReplicatedStorage.InventoryLoaded.OnClientEvent:Connect(function(plr)
changecolors()
end)
game.Players.LocalPlayer.CharacterAdded:Connect(function()
changecolors()
end)
This is my first topic on here, hopefully it’s straightforward and someone can help me figure this out.
The only thing the script prints is the “Color changed” in the while loop, yet the color doesn’t actually change in my gui. Also I own every effect listed when I check my inventory in the explorer, and all the icons appear in my inventory gui frame, they just don’t change color.
This might seem like an odd question but this is part of an update I’m not ready to release publicly, so is there a way I could test it without publishing it? Or making a copy of the game somehow? I’m sorry if this is a super well known feature that I don’t know about
I just tried this method using newtemplate.ImageButton when the template is cloned and inv.v.Image button when the gui already exists in the frame. I’m not sure which one is running but it’s still printing “Color changed” without actually changing the color of the gui
The spawn function can be added whenever you use a while loop to ensure the rest of the code can still run. Not sure if this will help your entire situation, but it’s worth a try.