Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

So I'm making a gun it works but the ammo won't show in my TextLabel, can anyone help?

local ammo = script.Parent.Ammo.Value
local ammoGui = game.StarterGui.GunGui.BackgroundFrame.AmmoDisplay

local function onUpdateAmmoDisplay()
	while wait() do
		ammoGui.Text = ammo.."/"..maxAmmo
	end
end
spawn(onUpdateAmmoDisplay)


3 comments

0

I know it's a stupid question, but I can't figure it out lol

0

see Verdomme's answer

0

I don't think you defined ammo correctly. Try rereading and rewriting your code.

1 answer

✓ Accepted answer

you are modifying the StarterGui, everything thats inside the startergui gets cloned into the PlayerGui of a player so if you modify something in StarterGui it will only show after the players dies so if you want the modify it instantly you have to modify the PlayerGui

the PlayerGui is part of the player. like this Player.PlayerGui

2 comments

0

@VerdommeMan Thank you so much! That saved me hours!

0

No problem also i think brady i s rigth, ammo has the value Ammo.Value, but not the reference of Ammo so anything u change to ammo riight now will not affect Ammo (ammo being here the name of var and Ammo is script.Parent.Ammo))

This discussion is preserved as it was. New answers, comments, and votes are closed.