here is my current code
local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(2,10,5)
part.Parent = workspace
local rotation = CFrame.Angles(0,0,0)
function mouseMove()
local ray = Ray.new(cam.CoordinateFrame.p, (mouse.Hit.p - cam.CoordinateFrame.p).unit * 5000)
local part2, position,normal = workspace:FindPartOnRayWithIgnoreList(ray, {part,player.Character}, false, true)
if position then
part.CFrame = CFrame.new(position+(normal*(part.Size/2))) *rotation
end
end
mouse.Move:Connect(function() mouseMove() end)
mouse.KeyDown:Connect(function(key)
if key == "r" then
rotation = rotation * CFrame.Angles(0,math.pi/2,0)
elseif key == "t" then
rotation = rotation * CFrame.Angles(math.pi/2,0,0)
end
mouseMove()
end)
It works fine, until you press "t", then it begins to float over the air a bit. https://gyazo.com/836a6869b52eb80cc6a1d3bd6c183b47
I'm trying to make it stay on the ground.

1 comment
Mouse.KeyDown is deprecated