Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to update this armor UI?

Asked by 3 years ago

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)
0
What's the script that fires? MiAiHsIs1226 189 — 3y
0
@MiAiHsIs1226 There's a code in the local script to fire whenever someone clicks on the tool. It's just a simple :FireServer() TheBuliderMC 84 — 3y

Answer this question