I typed all the scripts and tested it it doesn’t work.
Here is the output -
here is the script -
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local tool = script.Parent.Parent
-- configs and varibles
local configs = script.Parent.Parent:WaitForChild("Configs")
local ammo = configs:WaitForChild("Ammo")
local reserveAmmo = configs:WaitForChild("ReserveAmmo")
local magSize = configs:WaitForChild("MagSize")
-- UI's
local Gui = script:WaitForChild("Gui")
local Frame = script.Gui:WaitForChild("AmmoFrame")
local ammolabel = Frame:WaitForChild("Ammo")
local reserveAmmoLabel = Frame:WaitForChild("ReserveAmmo")
-- functions
local function update()
ammolabel.Text = tostring(ammo.Value)
reserveAmmoLabel = tostring(reserveAmmo.Value)
if ammo.Value < math.floor(magSize.Value * 0.2) then
ammolabel.TextColor3 = Color3.fromRGB(200, 0, 0)
else
ammolabel.TextColor3 = Color3.fromRGB(255, 255, 255)
end
if reserveAmmo.Value < math.floor(magSize.Value * 0.2) then
reserveAmmoLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
else
reserveAmmoLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- this is the error part
end
end
-- eventlistener
ammo.Changed:Connect(update)
reserveAmmo.Changed:Connect(update)
tool.Equipped:Connect(function()
Gui.Parent = playerGui
update()
end)
tool.Unequipped:Connect(function()
Gui.Parent = script
end)
--initialize
update()
My explorer(might be helpful) -
(I have not included the gun parts.but ask me if I want to include them)
Try using “Color3.new()” insteadof Color3.fromRGB().
So here’s the entire script with just that changed (just copy and paste it in and let me know how it goes):
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local tool = script.Parent.Parent
-- configs and varibles
local configs = script.Parent.Parent:WaitForChild("Configs")
local ammo = configs:WaitForChild("Ammo")
local reserveAmmo = configs:WaitForChild("ReserveAmmo")
local magSize = configs:WaitForChild("MagSize")
-- UI's
local Gui = script:WaitForChild("Gui")
local Frame = script.Gui:WaitForChild("AmmoFrame")
local ammolabel = Frame:WaitForChild("Ammo")
local reserveAmmoLabel = Frame:WaitForChild("ReserveAmmo")
-- functions
local function update()
ammolabel.Text = tostring(ammo.Value)
reserveAmmoLabel = tostring(reserveAmmo.Value)
if ammo.Value < math.floor(magSize.Value * 0.2) then
ammolabel.TextColor3 = Color3.new(200, 0, 0)
else
ammolabel.TextColor3 = Color3.new(255, 255, 255)
end
if reserveAmmo.Value < math.floor(magSize.Value * 0.2) then
reserveAmmoLabel.TextColor3 = Color3.new(255, 0, 0)
else
reserveAmmoLabel.TextColor3 = Color3.new(255, 255, 255) -- this is the error part
end
end
-- eventlistener
ammo.Changed:Connect(update)
reserveAmmo.Changed:Connect(update)
tool.Equipped:Connect(function()
Gui.Parent = playerGui
update()
end)
tool.Unequipped:Connect(function()
Gui.Parent = script
end)
--initialize
update()