Tool not cloning into workspace when cloned from ServerStorage

Hello everyone.
I’m trying to find a way to clone a log (tool) into the workspace from server storage. Not sure if I’m missing something or I did something wrong, and I’m getting really confused.

local serverStorage = game:GetService("ServerStorage")
local log = serverStorage.Resources.Log
local logCopy


script.Parent.Touched:Connect(function(obj)
	if obj.Name == ("Handle") then
		script.Parent.Anchored = false
		task.wait(2)
		logCopy = log:Clone()
		logCopy.Handle.Position = script.Parent.Position
		logCopy.Parent = game.Workspace
		script.Parent:Destroy()
	end
end)

maybe the tool is not anchored and fall out of the map

local serverStorage = game:GetService("ServerStorage")
local logTool = serverStorage.Resources.Log
local logCopy


script.Parent.Touched:Connect(function(obj)
	if obj.Name == ("Handle") then
		script.Parent.Anchored = false
		task.wait(2)
		logCopy = logTool:Clone()
		logCopy.Handle.Position = script.Parent.Position
		logCopy.Parent = game.Workspace
		script.Parent:Destroy()
	end
end)

Try this.

That’s definitely not the problem, even if it wasn’t anchored it shouldn’t clip through the ground.


local serverStorage = game:GetService("ServerStorage")
local logg = serverStorage.Resources.Log
local logCopy = nil


script.Parent.Touched:Connect(function(obj)
	if obj.Name == ("Handle") then
		script.Parent.Anchored = false
		task.wait(2)
		logCopy = logg:Clone()
		logCopy.Handle.Position = script.Parent.Position
		logCopy.Parent = game.Workspace
		script.Parent:Destroy()
	end
end)

Try this script. Is it a server script btw?

Yes, it is a server script. character limit

Okay. character limit character limit

This is odd, both you and @Pegagittt scripts worked, it’s just not cloning in the right position. I’m trying to make a tree fall down when an axe hits it, and clone it which has worked as I said but it’s not cloning where the tree is.

1 Like

Im assuming logCopy.Handle is the log that falls and script.Parent is the tree?

logCopy.Handle is the log/tool that needs to be cloned, and script.Parent is the tree that falls down.

1 Like

You should consider defining logCopy inside the function instead of outside of it, otherwise you may accidentally share the same instance between several function calls which could cause unexpected behavior, especially since you have a wait().

1 Like

local serverStorage = game:GetService("ServerStorage")
local logg = serverStorage.Resources.Log
local logCopy = nil


script.Parent.Touched:Connect(function(obj)
	if obj.Name == ("Handle") then
		script.Parent.Anchored = false
		task.wait(2)
		logCopy = logg:Clone()

		logCopy.Parent = game.Workspace
		logCopy.Handle.CFrame = script.Parent.CFrame + Vector3.new(0,1,0)
logCopy.CanCollide = true
task.wait()
		script.Parent:Destroy()
	end
end)

Also are there any errors after this code is run?

Yeah, it said CanCollide is not a valid member of tool workspace.Log or something like that, and also the tree did not destroy itself and the log just started multiplying. Not sure what happened there. It did clone in the right spot so that’s better than nothing.

1 Like

Whoops, forgot logCopy is a tool :joy:


local serverStorage = game:GetService("ServerStorage")
local logg = serverStorage.Resources.Log
local logCopy = nil


script.Parent.Touched:Connect(function(obj)
	if obj.Name == ("Handle") then
		script.Parent.Anchored = false
		task.wait(2)
		logCopy = logg:Clone()

		logCopy.Parent = game.Workspace
		logCopy.Handle.CFrame = script.Parent.CFrame + Vector3.new(0,1,0)
		script.Parent:Destroy()
	end
end)

The error broke the code so the tree didn’t disappear

2 Likes

It’s all good haha, I always mix up variables too, it works now though so big thanks!

2 Likes

logCopy.Handle.Position = script.Parent.Position after logCopy.Parent = game.Workspace

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