How to find the tool in the script?

I am trying to find a way to find the tool inside the player’s character went they equip it but it does not seem to work. What did I do wrong?

---------------------------------FTN GAMING----------------------------------------------
player = script.Parent.Parent.Parent.Parent.Parent

local function buy(plr)

	if script.Parent.Text == "Open Second Lightsaber" then
		plr.Character:WaitForChild("YellowLightsaber").Sword2.Transparency = 0
		script.Parent.Text = "ClosedLightsaber2"
		print("Worked")
	elseif script.Parent.Text == "ClosedLightsaber2" then
		plr.Character:WaitForChild("YellowLightsaber").Sword2.Transparency = 1
		script.Parent.Text = "Open FIrst LightSaber"




	end
end



script.Parent.MouseButton1Down:connect(buy)

When a player equipt a Tool it will automatically parented to it’s character found in Workspace.

So what I’m gonna do is:

-- Script
local player = workspace.Roblox --Example only
if player.Character:FindFirstChild("Tool Name") then
    print("Tool Name Equipped")
else
    print("Not equipped.")
end

So this would find the player and be able to find the tool inside them when equipped?

local player = script.Parent.Parent.Parent.Parent.Parent
if player.Character:FindFirstChild("Tool") then
    print("found tool")
end

Don’t you see I cant do that you cant define a tool when its equipped to the body that’s what I am doing.

Let me try that right now Thanks.

How about this now?

---------------------------------FTN GAMING----------------------------------------------
player = script.Parent.Parent.Parent.Parent.Parent


local function buy()
	
	if script.Parent.Text == "Open FIrst LightSaber" then
		
		player.Character:FindFirstChild("YellowLightsaber").Sword1.Transparency = 0
			
		
		script.Parent.Text = "ClosedLightsaber"
		print("Worked")
	elseif script.Parent.Text == "ClosedLightsaber" then
		player.Character:FindFirstChild("YellowLightsaber").Sword1.Transparency = 0
		script.Parent.Text = "Open FIrst LightSaber"
	
		
		
		
		end
	end
	
	

script.Parent.MouseButton1Down:connect(buy)