I put the Value "Ammo" inside of the script as a child. When I run the script, it says it's not a valid member. Why is this happening?
local player = game.Players.LocalPlayer local humanoid = script.Parent:FindFirstChild("Humanoid") local ammo = script.Ammo local barrel = humanoid.Parent.AnimPistol.Barrel local grip = humanoid.Parent.AnimPistol.GAssembly.Grip local trigger = humanoid.Parent.AnimPistol.GAssembly.Trigger local canShoot = false local coolDown = true local keyBind = "f" local mouse = player:GetMouse() mouse.KeyDown:Connect(function(key) if key == keyBind then if ammo.Value ~= 0 and coolDown == true then canShoot = true end if canShoot == true then barrel.Transparency = 0 grip.Transparency = 0 trigger.Transparency = 0 wait(.5) local animation = humanoid:LoadAnimation(script.Animation) animation:Play() wait(animation.Length) barrel.Transparency = 1 grip.Transparency = 1 trigger.Transparency = 1 ammo.Value -= 1 canShoot = false coolDown = false wait(60) coolDown = true end end end)
Replace line 03 with
local ammo = script:WaitForChild("Ammo")