When using Mouse.Hit.p, I came across a problem, when I say

model:MoveTo(mouse.Hit.P)

the model is always moving up when it is meant to only be moving on the ground, here is my script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local function getKey()
	mouse.KeyDown:connect(function(Key)
		if Key == "x" then
			return true
		end
	end)
end

local function place(model, clone)
	assert(model:IsA("Model"), "Please insert a propper name to insert.")
	if clone then
		local thing = model:Clone()
		thing.Parent = workspace
		if thing then
			local player = game.Players.LocalPlayer
			local mouse = player:GetMouse()
			repeat
				wait()
				thing:MoveTo(mouse.Hit.p)
			until getKey() == true
		end
	end
end



script.Parent.Road.MouseButton1Click:connect(function()
	place(game.ReplicatedStorage.Models.Road, true)
end)

1 comment

0

I have this same problem