Im trying to make a button visible but only if the player is holding the specific tool that is in their inventory, Please give me a simple script idea on how to detect if a player is holding the tool please help <3
EDIT: this is my updated script and it works except that the button doesnt stop showing when i stop holding the tool:
local Tool = script.Parent
Tool.Equipped:Connect(function()
local player = game.Players:GetPlayerFromCharacter(Tool.Parent)
if player then
local playerGui = player:FindFirstChildOfClass(“PlayerGui”)
if playerGui then
playerGui:WaitForChild(“ScreenGui”):WaitForChild(“ToolBtns”):WaitForChild(“Wave1Btn”).Visible = true
end
end
end)
Tool.Unequipped:Connect(function()
local player = game.Players:GetPlayerFromCharacter(Tool.Parent)
if player then
local playerGui = player:FindFirstChildOfClass(“PlayerGui”)
if playerGui then
playerGui:WaitForChild(“ScreenGui”):WaitForChild(“ToolBtns”):WaitForChild(“Wave1Btn”).Visible = false
end
end
end)