I’m trying to make a prompt appear on the client whenever they equip a tool and disappear whenever it is unequipped. It works perfectly fine, but the problem is when I use the prompt and it deletes the tool the prompt disables for a split second and then re-enables itself. I want the prompt to stay disabled once the tool is destroyed.
Video of prompt working and not working when used
Local Script (inside of tool)
local player = script.Parent.Parent.Parent
local Tool = script.Parent
Tool.Equipped:Connect(function()
for i,object in pairs(game.Workspace:GetDescendants()) do
if object.Name == "SmashPrompt" and object:IsA("ProximityPrompt") then
if object.Parent.Disabled.Value == false then
object.Enabled = true
end
end
end
end)
Tool.Unequipped:Connect(function()
for i,object in pairs(game.Workspace:GetDescendants()) do
if object.Name == "SmashPrompt" and object:IsA("ProximityPrompt") then
object.Enabled = false
end
end
end)
Server Script
local Object = script.Parent
local ProximityPrompt = script.Parent.SmashPrompt
local disabled = script.Parent.Disabled
local debounce = false
ProximityPrompt.Triggered:Connect(function(player)
local crowbar = player.Character:FindFirstChild("Crowbar")
if crowbar and debounce == false then
--and player.Team == "Crew" for when i make teams and its anti-exploitable
--debounce = true
--play animation
crowbar:Destroy()
print("box smashed")
disabled.Value = true
ProximityPrompt.Enabled = false
end
end)