ammo = game.Players:FindFirstChild(player.Name):FindFirstChild('Backpack'):FindFirstChild('Tool'):FindFirstChild('Ammo')
This is my line of code. When I call it, it tells me it Attempted to index a nil value
. Any help? I checked the path, and it does exist. I can't figure out this problem.
Hello KillerKill! If I am correct you're looking to make a gun? I have found a solution to your problem, all it requires is a Local Script.
Here's the code:
local ammo = game.Players.LocalPlayer:FindFirstChild("Backpack"):FindFirstChild("Tool"):FindFirstChild("Ammo");
If you really badly want to have a specific player, then here's the code for that:
if game.Players:FindFirstChild("Player") then plr = game.Players.Player; local ammo = plr.Backpack:FindFirstChild("Tool"):FindFirstChild("Ammo"); print(ammo.Value); else print("Player Not here"); end
See if you can edit that code, and get what you need out of it.
Love always, Luciferic Luci.