I’ve tried 2 types of proximity triggers, nothing has worked so far
local CurrentAmmo = 0
local AmmoLimit = 1
local ProperName = "Shell"
script.Parent.Triggered:Connect(function(player)
print("fire?")
if player.Backpack:FindFirstChildWhichIsA("Tool") then
print("1")
local tool = player.Backpack:FindFirstChildWhichIsA("Tool")
if tool.Name == ProperName then
print("2")
if CurrentAmmo < AmmoLimit then
print("4")
tool:Destroy()
CurrentAmmo = CurrentAmmo + 1
game.Workspace.ScriptedArtillery.Gun.ProximityPrompt.ActionText = "Load Shell (1/1)"
end
end
end
end)
Then that means there is no tool inside of the player backpack. Are you sure they have a tool there? Maybe you have the tool equipped when you are using the prompt, in which case the tool would be inside of the Character of the player.
Try changing it to this instead:
local CurrentAmmo = 0
local AmmoLimit = 1
local ProperName = "Shell"
script.Parent.Triggered:Connect(function(player)
print("fire?")
local tool = player.Backpack:FindFirstChildWhichIsA("Tool") or player.Character:FindFirstChildWhichIsA("Tool")
if tool then
print("1")
if tool.Name == ProperName then
print("2")
if CurrentAmmo < AmmoLimit then
print("4")
tool:Destroy()
CurrentAmmo = CurrentAmmo + 1
game.Workspace.ScriptedArtillery.Gun.ProximityPrompt.ActionText = "Load Shell (1/1)"
end
end
end
end)