Proximity Prompt action text not changing

I made a script thats supposed to change the action text of a proximity prompt if the players character has a tool inside of it.

But its not working.

local prompt = script.Parent

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		for _, v in pairs(char:GetChildren()) do
			if v:IsA("Tool") then
				prompt.ActionText = "Place " .. v.Name
				print("prompt actiontext changed")
			end
		end
	end)
end)
1 Like

try using prints to see if V is returning as a Tool or not

2 Likes

You also may need to use a while loop so that it constantly checks for a tool

1 Like

If you’re using a proximityPrompt you can simply use the Trigger Event. It’ll get the player which you can then get the character from. After that you can check if the player has a tool currently “equipped”. That should work.

Your code will only work every time the character is loaded and the tool is in their character…

1 Like

this will only checks if the player has the tool once

1 Like

oh so how do i make it check like forever i guess?

If your looking to check when a player equips a tool you can do this

local prompt = script.Parent
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.ChildAdded:Connect(function(child)
			if child:IsA("Tool") then			
				prompt.ActionText = "Place " .. v.Name
				print("prompt actiontext changed")
			end
		end)
	end)
end)

No? This isn’t needed. Just check if a child gets added to the player’s character when a tool is equipped from the player’s backpack.

It works thank you so much! btw you forgot to change v to child.Name

1 Like

That’s another method that would work.

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