Noskur2
(Noskur2)
May 30, 2019, 6:41pm
#1
https://gyazo.com/e9562e8769693b4cdefa1010ffc86363
local brick = Instance.new("Part",workspace)
brick.Anchored = true
SNAP = 2
local M = game.Players.LocalPlayer:GetMouse()
M.TargetFilter = brick
M.Move:Connect(function()
local CF = CFrame.new(math.floor(M.Hit.X / SNAP + 0.5)* SNAP,math.floor(M.Hit.Y / SNAP + 0.5)* SNAP,math.floor(M.Hit.Z / SNAP + 0.5)* SNAP)
--print(game.Players.LocalPlayer:GetMouse().Target.Name)
brick.CFrame = CF
end)
M.Button1Down:Connect(function()
brick:Clone().Parent = workspace
end)'
Having trouble with math here.
I am a advanced scripter but I am really bad at math
I Don’t know why it keeps phasing into the ground
I have tried changing the 0.5 but that makes it wrose and changes the offset of the brick So please help
Locard
(Locard)
May 30, 2019, 6:44pm
#3
The origin of your part is at its center, so if you want it to not phase through the bottom you have to shift it up by half its height after the initial CF placement.
CF = CF * CFrame.new(0,part.Size.y*.5,0)
Noskur2
(Noskur2)
May 30, 2019, 6:44pm
#4
ok, I’ll check it out thanks. Hope it helps
Noskur2
(Noskur2)
May 30, 2019, 6:49pm
#5
It works great but the Y offset is still a bit off
https://gyazo.com/ffce09cad1a826ceb1bff030c5b0fd18
Locard
(Locard)
May 30, 2019, 7:00pm
#6
It looks like your part is bigger than the increment you want. If you switch to a part with a size 2x1x4 then you shouldn’t be seeing that.
I tried your code and the size was 1.2 on the Y for the part created, not 1.
2 Likes
Noskur2
(Noskur2)
May 30, 2019, 7:20pm
#8
Oh yes thanks you I did not see that
1 Like