Part keeps going under baseplate

Hello!
I made a script where a part follow’s your mouse position, it works great and all, but the part keeps going under the baseplate. I couldn’t find anything with my issue on the forums, not even on scriptinghelpers.

You could try optimizing the system to not allowing the Part’s Y axis to go below 0

local part = Instance.new("Part") -- Just an example part
part.Parent = workspace

local position = part.Position -- the part's current position

-- example condition
if position.Y < 0 then
    part.Position = Vector3.new(position.X, 0, position.Z) -- set the part's position
end

Also make it so if its under baseplate according to the position that acts like under baseplate then teleport it back. or you can just make the baseplate to this like this. so it wont cause it. @HugeCoolboy2007

2 Likes

Didn’t work, I should’ve mentioned my script:

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")

local part = Instance.new("Part", workspace)
Mouse.TargetFilter = part

RunService.RenderStepped:Connect(function()
	part.Position = Mouse.Hit.Position
end)
userinputservice.InputBegan:Connect(function(input, gp)
	if input.KeyCode == Enum.KeyCode.M then --Change K to any keyboard button
		Player.Character:MoveTo(Mouse.Hit.p)
	end
end)

local position = part.Position

if position.Y < 0 then
	part.Position = Vector3.new(position.X, 0, position.Z) -- your code here
end

Actually, the issue somehow fixed itself, thanks for helping anyways.

1 Like