Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a Proximity Prompt appear and do function when the player has a tool?

I've tried detecting the player backpack for the tool name and if it does detect it I made it to where the Proximity Prompt should be allowed to be triggered. I may be going in a completely wrong direction. Here's my code:

local ProximityPromptService = game:GetService("ProximityPromptService") local ToolName = "Wrench" local core = script.Parent.Parent.Effect.Core local coreMiniSparks = script.Parent.Parent.Effect.CoreMiniSparks local miniSparks = script.Parent.Parent.Effect.MiniSparks local sparks = script.Parent.Parent.Effect.Sparks game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if player.Backpack:FindFirstChild(ToolName) then script.Parent.Triggered:Connect(function() core.Enabled = false coreMiniSparks.Enabled = false miniSparks.Enabled = false sparks.Enabled = false end) end end)

end)

2 comments

0

Please, use a code block instead of plain text... It's hurting my eyes.

0

So, you want to enable a proximity prompt when you equip the tool?

2 answers

local ProximityPromptService = game:GetService("ProximityPromptService")
local ToolName = "Wrench"
local core = script.Parent.Parent.Effect.Core
local coreMiniSparks = script.Parent.Parent.Effect.CoreMiniSparks
local miniSparks = script.Parent.Parent.Effect.MiniSparks
local sparks = script.Parent.Parent.Effect.Sparks
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Backpack:FindFirstChild(ToolName) then
			script.Parent.Triggered:Connect(function()
				core.Enabled = false
				coreMiniSparks.Enabled = false
				miniSparks.Enabled = false
				sparks.Enabled = false
		end)
	end
	end)
end)

here's his script ina code block if anyone wants to help

1 comment

0

off the top of my head, my suggestion would be to use a debounce to allow ur ProximityPrompt to be enabled

local ToolName = "Wrench" 
local core = script.Parent.Parent.Effect.Core
local coreMiniSparks = script.Parent.Parent.Effect.CoreMiniSparks local miniSparks = script.Parent.Parent.Effect.MiniSparks
local sparks = script.Parent.Parent.Effect.Sparks
script.Parent.Triggered:Connect(function(player)
local backpack,char=player:FindFirstChild"Backpack",player.Character
local tool=backpack and backpack:FindFirstChild(ToolName)or char and char:FindFirstChild(ToolName)
if tool then
coreMiniSparks.Enabled = false 
miniSparks.Enabled = false 
sparks.Enabled = false
end
end)

1 comment

0

I think it's easier to do if a player has a tool then proximity prompt will work then if doesn't have then it won't

This discussion is preserved as it was. New answers, comments, and votes are closed.