Script will not delete, add or change proximity name, help appreciated

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)

Which of the “prints” are getting fired? Is this a LocalScript or a Script, and where is it?

This is a server script located in the physical proximity prompt, “fire?” is the only print that is firing

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)

they do, i will see if it works with your script

Thanks, the script worked just nicely

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.