I got some help with a armor system with a friend and I'm currently making a UI above someone's head. I want it to show that they have armor on, so here's the code whenever the armor changes.

local armor = script.Parent.Frame.Armor
local Armor = script.Parent.Parent.Parent:WaitForChild("Folder"):WaitForChild("Armor"):WaitForChild("CurrentArmor")
local Armor2 = script.Parent.Parent.Parent:WaitForChild("Folder"):WaitForChild("Armor"):WaitForChild("MaxArmor")

Armor:GetPropertyChangedSignal("Value"):Connect(function()
	local healthChange = Armor.Value/Armor2.Value
	armor:TweenSize(UDim2.new(healthChange,0,1,0),"In","Linear",0.01)
end)

Problem is that, whenever you put on the armor, it doesn't change until that person takes damage. Is there anything I can do?

script that changes the armor value:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
	--script.Parent.Parent:WaitForChild("Head"):WaitForChild("BillboardGui").Frame.Armor.Visible = true
	print("AR")
	script.Parent.Parent.Folder.Armor.CurrentArmor.Value += 100
	script.Parent.Parent.Folder.Armor.MaxArmor.Value += 100
	script.Parent:Destroy()
end)

2 comments

0

What's the script that fires?

0

@MiAiHsIs1226 There's a code in the local script to fire whenever someone clicks on the tool. It's just a simple :FireServer()