It for some reason doesn't work, as I have a tool which does is clones the tool into the users backpack. I tested it in starterpack, which it worked, but when I input it in the script of that tool and cloned it to the backpack, it for some reason doesnt function. This is the local script of my tool i have been trying to make work.
local tool = script.Parent local player = game.Players.LocalPlayer local rp = game:GetService("ReplicatedStorage") local hum = player.CharacterAdded:Wait():WaitForChild("Humanoid") local TweenService = game:GetService("TweenService") local mouse = player:GetMouse() local BarrageEvent = rp:WaitForChild("VampiricBarrage") local holdingdown = false local holdingdowncooldown = 0.66666668653488 --[[ tool.Activated:Connect(function() BarrageEvent:FireServer(tool) end) ]] function checkTool(character,toolName) for _, v in pairs(character:GetChildren()) do if v:IsA("Tool") then if v.Name == toolName then return true end end end return false end mouse.Button1Down:Connect(function() if checkTool(player.Character,tool.Name) then holdingdown = true repeat BarrageEvent:FireServer(tool) wait(holdingdowncooldown) until not holdingdown end end) mouse.Button1Up:Connect(function() if checkTool(player.Character,tool.Name) then holdingdown = false end end) tool.Unequipped:Connect(function() holdingdown = false end)
You need to put it in lighting because it doesn't work in replicated storage,You just need to put the item in Lighting instead of replicated storage
local tool = script.Parent local player = game.Players.LocalPlayer local rp = game:GetService("Lighting") local hum = player.CharacterAdded:Wait():WaitForChild("Humanoid") local TweenService = game:GetService("TweenService") local mouse = player:GetMouse() local BarrageEvent = rp:WaitForChild("VampiricBarrage") local holdingdown = false local holdingdowncooldown = 0.66666668653488 --[[ tool.Activated:Connect(function() BarrageEvent:FireServer(tool) end) ]] function checkTool(character,toolName) for _, v in pairs(character:GetChildren()) do if v:IsA("Tool") then if v.Name == toolName then return true end end end return false end mouse.Button1Down:Connect(function() if checkTool(player.Character,tool.Name) then holdingdown = true repeat BarrageEvent:FireServer(tool) wait(holdingdowncooldown) until not holdingdown end end) mouse.Button1Up:Connect(function() if checkTool(player.Character,tool.Name) then holdingdown = false end end) tool.Unequipped:Connect(function() holdingdown = false end)