Ok so I have been doing lua for quite a while yet I still run into issues, is there any way I could fix this?

here is the video link to my issue: https://www.youtube.com/watch?v=xtiGcpcPlvY

here is my script: 
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local x = mouse.X
local y = mouse.Y
local mtarget
local down
local treenames = {'AppleTree','BeginnersTree'}
for _,v in pairs(treenames) do
	print(v)
	mouse.Button1Down:connect(function()
		if mouse.Target ~= nil and mouse.Target.Parent.Name == v then
			mtarget = mouse.Target.Parent
			print(mouse.Target.Parent.Name)
			down = true
			mouse.Move:connect(function()
				if down and mtarget ~= nil then
					mtarget:MoveTo(mouse.Hit.p,x,y)
				end
			end)
			mouse.Button1Up:connect(function()
				down = false
				mtarget = nil
			end)
		end
	end)
end

2 comments

0

i'm not sure but this might be on roblox. maybe set it to a certain y so it doesnt come floating to you? (just a random solution for a flat baseplate)

0

Alright thanks!