Tool script doesnt work?

So I have created a tool that contain the tool.Activated event in it, now no matter what I do the tool.Activated never runs, I have put prints in there to see if the script runs in general and yes it does.
My guess is it has to do with the fact that I am storing this tool in a folder in replicatedStorage and then I clone it and put it into the players backpack, Ive tried everything I could think of but so far the tool.Activated just wont run.

The script in the tool(Its a local script)

local tool = script.Parent

-- services
local player = game:GetService('Players').LocalPlayer

local PlayerGui = player:FindFirstChild('PlayerGui')
local starter = game:GetService('StarterGui')
local gui = starter:WaitForChild('CollectHeart',30)

local buttons = gui:FindFirstChild('Frame'):FindFirstChild('Buttons')

local store = buttons:FindFirstChild('Store')
local drop = buttons:FindFirstChild('Drop')

tool.Activated:Connect(function()
	warn('Triggered') -- doesnt run
end)

warn('z') -- runs

The script that parents the item(Server script)

module.SpawnHeart = function()
	local name = 'Soul'
	local heartType = module.Hearts[name]
	local heartInfo = heartsFolder:FindFirstChild(name)
	
	local heart:Part = heartInfo:FindFirstChild('PickUp').Value:Clone()
	local prompt = script:FindFirstChild('Promt'):Clone()
	
	prompt.ActionText = '[ TAKE ]'
	prompt.ObjectText = '['..string.upper(name..' heart')..']'
	
	prompt.Parent = heart
	heart.Parent = workspace
	
	prompt.Triggered:Connect(function(player) -- pick up item
		-- setup
		-- this gives the player a tool.
		local pickupTool:Tool = heartInfo:FindFirstChild('PickUpTool').Value:Clone() -- make user pick it up by giving them a tool of it
		
		pickupTool.RequiresHandle = false
		pickupTool.CanBeDropped = false
		
		local handle = heart:Clone() -- clone the heart so we have the model
		handle.Name = 'z'
		handle.Parent = pickupTool
		
		pickupTool.Parent = player:FindFirstChild('Backpack') -- parent it
		

		
		
		handle:FindFirstChildOfClass('ProximityPrompt'):Destroy() -- remove the prompt
		heart:Destroy() -- remove ground item
		
		
	end)
	
	debris:AddItem(heart,DebrisTime * 60) -- remove item after X amount of time
end
1 Like

It’s weird, that the tool.Activated event is not firing, can you record a video of what happens?

2 Likes

Ps you cant tell but I am clicking

when inside the Roblox game press shift + F9 to open the console window so you can check if there’s an error.

It doesn’t matter which it was located as long as it has Activated() listener for localplayer.

My guess is that the gui is not yet reloaded and you use WaitForChild('CollectHeart', 30). I can see that you use 30 seconds of yield time meaning, the WaitForChild will pause the localscript for 30 seconds until it find the CollectHeart instance.

I suggest that you can just put the CollectHeart inside ReplicatedStorage.