Anyways, this is an ammo box script, designed mostly for TurboFusion's gun scripts. Anyways, what I need this script to do, is to figure out the name of the tool instead of the classname, so if the gun's named "Double Shotgun" or "Auto Shotgun" the script will only give ammo to those two gun types. Also, there's a glitch where you have 199 ammo, it'll give you 219, which I have no idea how to fix. If someone could help me with the bug, and making it so it'll read the name of the tool, and not the classname, that'd be EXTREMELY helpful!!
Here's the code:
function onTouched(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
local d = hit.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Tool") then
if d[i].Ammo.Value == 200 then --This is the max ammo for the gun.
return nil
else
d[i].Ammo.Value = d[i].Ammo.Value +20
script.Sound:play()
script.Parent.AmmoLeft.Value = script.Parent.AmmoLeft.Value -0
script.Disabled = true
script.Parent.Transparency = 1
wait(10)
script.Disabled = false
script.Parent.Transparency = 0
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

2 comments
I personally don't think you have a clue about Lua scripting. You said you wanted it to recognize a tool by its Name, not className. There is a simple fix on line 5 for that...
Actually, I do know Lua scripting. It's just certain things I don't know about.