Hello,
I am having an issue with displaying a gun’s ammo. I have a screen gui with a text label in it, and it’s a child of the server script for a gun tool. Upon the player equipping the tool, it clones the gui to the tool holder’s PlayerGui, and sets the text to the ammo of the gun.
Only problem is, the text doesn’t ever update! It just stays as “Label” forever, but bizarrely, upon unequipping the gun tool the text updates for about a frame when destroying the clone of the ammo gui.
Additionally, I am also manually looking at the text of the cloned gui while in game, and the text of the gui instance is changed to the ammo correctly, but the gui on screen doesn’t display these changes!
My ammo is an IntValue that is a child of the same server script.
Here’s the code that clones the gui upon the player equipping the tool:
tool.Equipped:Connect(function()
local ammoGui = script.AmmoGui:Clone()
ammoGui.AmmoStatus.Text = ammo.Value.."/25"
ammoGui.Parent = game.Players:GetPlayerFromCharacter(tool.Parent).PlayerGui
end)
And here’s the code that’s supposed to update the gui:
ammo:GetPropertyChangedSignal("Value"):Connect(function()
if game.Players:GetPlayerFromCharacter(tool.Parent) then
game.Players:GetPlayerFromCharacter(tool.Parent).PlayerGui.AmmoGui.AmmoStatus.Text = ammo.Value.."/25"
end
end)
And finally here, the on-screen gui text is just “Label” while in the properties of the gui its text is “25/25”