Tool scripts not working when equipped using a script

So, I made a crafting system that allows you to create your own tools.

When they’re created they’re parented to the player’s backpack.

However once they are there, when I try to equip them they don’t work.

If I place them in StarterPack they work just fine.

I don’t know that could be happening so some help would be appreciated.

Are you giving the tool with a local script? If yes then that’s the problem, do it on the server.

Im doing it on the server (words)

Are you getting the player in the tool’s script? Get him when the tool is equipped. (Just some basic stuff right now)

I get the player from a remote event. See:

when you click that image label a remote event is fired to the server with the player, the stuff thats created, etc.

Thats how I get the player.

The server code is this:

local ts = game:GetService(“TweenService”)

game.ReplicatedStorage:WaitForChild(“FabricatorEvent”).OnServerEvent:Connect(function(plr, cells, name, class)
if script.Parent.Name == plr.Name … “Fabricator” then

	local model = game.ReplicatedStorage.FabricatorData.Classes:FindFirstChild(class).Models:FindFirstChild(name):Clone()
	
	local classfolder = game.ReplicatedStorage.FabricatorData.Classes:FindFirstChild(class)
	
	model:SetPrimaryPartCFrame(script.Parent.ObjectReference.CFrame * CFrame.Angles(0,0,math.rad(90)))
	
	model.Parent = script.Parent.OnCreation
	
	
	for i, cell in ipairs(cells) do
		cell.Name = "EmptyCell"
		cell.DataHolder.ItemImage.Image = ""
		cell.DataHolder.ItemName.Text = ""
	end
	
	local modelparts = model:GetChildren()
	
	local partcount = 0
	
	local realparts = {}
	
	local function gettime(fore)
		local part = modelparts[fore]
		if part then
			if part:IsA("MeshPart") or part:IsA("Part") or part:IsA("Union") then
				if model.PrimaryPart == part then
				else
					partcount += 1
					table.insert(realparts, part)
				end
			end
			end
	end
	
	table.foreach(modelparts, gettime)
	
	gettime()
	
	local timee = (2.7/partcount)/2
	
	local ti = TweenInfo.new(
		timee,
		Enum.EasingStyle.Quad,
		Enum.EasingDirection.Out,
		0,
		false
	)
	
	
	local lasers = script.Parent.Lasers:GetChildren()
	
	for i, laser in ipairs(lasers) do
		laser.Beam.Enabled = true
		laser.LineForce.Enabled = true
	end
	
	local lid = script.Parent.Lid.Lid
	
	lid.WeldConstraint1.Enabled = false
	lid.WeldConstraint2.Enabled = false
	lid.WeldConstraint3.Enabled = false
	lid.WeldConstraint4.Enabled = false
	
	script.Parent.Body.Print:Play()
	
	for i, part in ipairs(realparts) do
		wait(timee)
		local tween = ts:Create(part, ti, {Transparency = 0})
		tween:Play()
	end
	
	
	
	for i, laser in ipairs(lasers) do
		laser.Beam.Enabled = false
		laser.LineForce.Enabled = false
	end
	
	if classfolder:FindFirstChild("Tool") then
		local tool = classfolder.Tool:FindFirstChild(model.Name)
		tool.Parent = plr.Backpack
	end

	lid.WeldConstraint1.Enabled = true
	lid.WeldConstraint2.Enabled = true
	lid.WeldConstraint3.Enabled = true
	lid.WeldConstraint4.Enabled = true
	
	model:Destroy()

	
	
end

end)

1 Like

K, I’ve managed to get it working.

the problem was that the main tool code had a CharacterAdded:Wait()

as the character was already there it waited forever.

Glad to ear it, I was hoping someone else would get it and you got it.

1 Like

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