Cloned tools not working

So, I have this randomizer game in which you spawn in with random tools and when you get the tools they just break with no error code I have tried many solutions but they didn’t work, please help.

Cloning script:

local items = rep:FindFirstChild("Items")
local melee = items:FindFirstChild("Melee"):GetChildren()
local ranged = items:FindFirstChild("Ranged"):GetChildren()
local misc = items:FindFirstChild("Misc"):GetChildren()
local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		task.wait(2)
		local ran1 = melee[math.random(1, #melee)]:Clone()
		local ran2 = ranged[math.random(1, #ranged)]:Clone()
		local ran3 = misc[math.random(1, #misc)]:Clone()
		ran1.Parent = plr.Backpack
		ran2.Parent = plr.Backpack
		ran3.Parent = plr.Backpack
	end)
end)

Local Script (the tool)

local dmg = 50
local cdtime = 10
local range = 6
local hitboxtime = 0.5
local delayer = 0.75
--actual script stuff
local atk = false
local cd = false
local equipped = false
local plr = game:GetService("Players").LocalPlayer
local char = plr.CharacterAdded:Wait(2)
local hum = char:WaitForChild("Humanoid")
local equip = script:FindFirstChild("equip")
local idle = script:FindFirstChild("idle")
local shoot = script:FindFirstChild("Animation")
local loader = hum:LoadAnimation(idle)
local equipload = hum:LoadAnimation(equip)
local load = hum:LoadAnimation(shoot)
print("hi")
script.Parent.Equipped:Connect(function()
	equipped = true
	equipload:Play()
	loader:Play()
end)
script.Parent.Unequipped:Connect(function()
	equipped = false
	equipload:Stop()
	loader:Stop()
	load:Stop()
end)
script.Parent.Activated:Connect(function()
	if cd == false then
		cd = true
		load:Play()
		script:FindFirstChild("RemoteEvent"):FireServer(char, dmg,range, char:FindFirstChild("HumanoidRootPart"), hitboxtime, delayer)
		task.wait(cdtime)
		cd = false
	end
end)
while equipped == false do
	equipload:Stop()
	loader:Stop()
	load:Stop()
	task.wait()
end```
2 Likes

If you test the tools in the StarterPack do they work as expected?

Yes I did and which worked perfectly.

Also inside the clone script that I wrote in the topic I accidently put in the local script for the tool in it. I’m a little new to creating topics.

During play, when you look in your character/the tool, does the directory look as it should?

Is anything missing from the tool during play?

No, inside the scripts nothing has been deleted the remote events are still in and also everything else.

You said “but they didn’t work”.

What is not working?

Oh, the local script isn’t printing anything as there is a “print(“hi”)” which isn’t working which seems like it just broke.

The tool is unusable is what I’m trying to say.

I’m sorry if I’m really bad at explaining.

Try adding a few more print statements.

And change the FindFirstChild to WaitForChild:

local dmg = 50
local cdtime = 10
local range = 6
local hitboxtime = 0.5
local delayer = 0.75
--actual script stuff
local atk = false
local cd = false
local equipped = false
local plr = game:GetService("Players").LocalPlayer
local char = plr.CharacterAdded:Wait(2)
local hum = char:WaitForChild("Humanoid")
local equip = script:FindFirstChild("equip")
local idle = script:FindFirstChild("idle")
local shoot = script:FindFirstChild("Animation")
local loader = hum:LoadAnimation(idle)
local equipload = hum:LoadAnimation(equip)
local load = hum:LoadAnimation(shoot)
print("hi")
script.Parent.Equipped:Connect(function()
	print("equipped")
	equipped = true
	equipload:Play()
	loader:Play()
end)
script.Parent.Unequipped:Connect(function()
	print("unequipped")
	equipped = false
	equipload:Stop()
	loader:Stop()
	load:Stop()
end)
script.Parent.Activated:Connect(function()
	print("activated")
	if cd == false then
		cd = true
		load:Play()
		script:WaitForChild("RemoteEvent"):FireServer(char, dmg,range, char:FindFirstChild("HumanoidRootPart"), hitboxtime, delayer)
		task.wait(cdtime)
		cd = false
	end
end)
while equipped == false do
	equipload:Stop()
	loader:Stop()
	load:Stop()
	task.wait()
end

It didn’t work, do you have any other solutions?

Not at the moment, and I have somewhere I need to go.

1 Like

Alright, thanks for the help. I’ll try to find a solution myself.

What script is the cloning script and where do you put it

Both scripts I put in are labeled at the top and I put it in ServerScriptService.

Try use local script for cloning and put it in startcharacter script

1 Like

It unfortunately didn’t work. I tried moving it into replicated storage which worked but it had the same problem last time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.