cloning = false
local Targ
local targClone
local Dragger

function onClone(mouse)
	if not cloning then
		cloning = true
		Targ = mouse.Target
		targClone = Targ:Clone()
		targClone.Parent = game.Workspace
		targClone.Position = Targ.Position + Vector3.new(0,.4,0)	
	
		Dragger = Instance.new("Dragger")
		pcall(function() Dragger:MouseDown(targClone, Vector3.new(0, 0, 0), {targClone}) end)
	    cloning = false
	end
	
end

function onMove(mouse)
	if Dragger then
		pcall(function() Dragger:MouseMove(targClone.UnitRay) end)
	else
		print(pcall(function() Dragger:MouseMove(targClone.UnitRay) end))
		wait(10)
	end
end


function onSelect(mouse)
	mouse.Button1Down:connect(function() onClone(mouse) end)
	mouse.Move:connect(function() onMove(mouse) end)
end

script.Parent.Selected:connect(onSelect)

This script is for a copy tool Im working on and its saying the Dragger value = nil, I don't understand why the value is nil.

1 comment

0

I have corrected the issue, I accidently wrote (targClone.UnitRay), I fixed it to say (mouse.UnitRay) and it works correctly now!