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