In this script a part will follow the mouse, I just want to know how you would use a Union from the lighting instead of a part, thanks.
tool = script.Parent function onButton1Down(mouse) local target = mouse.Target local q = Instance.new("Part", Workspace) q.Size = Vector3.new(3,3,3) q.Anchored = true q.CanCollide = False while true do wait() q.CFrame = CFrame.new(Vector3.new(tool.Parent.Humanoid.TargetPoint.X,0,tool.Parent.Humanoid.TargetPoint.Z)) end end function onEquipped(mouse) mouse.Button1Down:connect(function () onButton1Down(mouse) end) end tool.Equipped:connect(onEquipped)
(Apologies if I have tagged wrong/incorrectly)
Try the following
local tool = script.Parent local spawned = false function onButton1Down(mouse) if spawned then return end local target = mouse.Target local q = game.Lighting.Union:Clone() q.Parent = Workspace q.Size = Vector3.new(3,3,3) q.Anchored = true q.CanCollide = False spawned = true while spawned do wait() q.CFrame = CFrame.new(Vector3.new(tool.Parent.Humanoid.TargetPoint.X,0,tool.Parent.Humanoid.TargetPoint.Z)) end end function onEquipped(mouse) mouse.Button1Down:connect(function () onButton1Down(mouse) end) end tool.Equipped:connect(onEquipped)