What I was trying to build was a gui that pops up and shows the ammo that the gun has. The script works perfectly, but for some reason there’s an error that’s “Bugging” me, and I don’t know how to get rid of it.
The scripts’s job is the find a ceratin tool in its Inventory, and the Gui is supposed to say the NumberValue found in the tool. Here’s the Error:
local player = game.Players.LocalPlayer
local Char = player.Character
while wait() do
script.Parent.Text = Char:WaitForChild("Pistol").Configuration.CurrentBullets.Value
end
Weird this error should only appear when you used WaitForChild. Did you use it anywhere?
Edit:He scammed me by not putting WaitForChild in the code so i said that.
Well i guess i can’t help with this.
But i just want to say you can change the text when the ammos value changed instead of looping. That can make the game less lagging (If it does)
Instead of Char:WaitForChild(), use Plr.Backpack:FindFirstChild(). Also, change the second line of your script into local Char = Plr.Character or Plr.CharacterAdded:Wait(). This will make it so that it will wait for the players character to load so it won’t turn nil.