script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,HIT,orig)
local char = script.Parent
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {char}
local dir = (HIT.Position - orig).Unit
local ray = workspace:Raycast(orig,dir*100,params)
if ray then
if mode then
local part = Instance.new("Part")
part.Name = "Placeable"
part.Material = Material
part.Color = Color
part.Transparency = Transparency
local GridSize = 3 --> Amount of studs it will move on a grid.
part.Size = Vector3.new(GridSize,GridSize,GridSize)
part.Anchored = true
local Grid = Vector3.new(math.floor(ray.Position.X/GridSize+.5)*GridSize, math.floor(ray.Position.Y/GridSize+.5)*GridSize, math.floor(ray.Position.Z/GridSize+.5)*GridSize)
part.Position = Grid
part.Parent = workspace
else
if ray.Instance.Name == "Placeable" then
ray.Instance:Destroy()
end
end
end
end)
well u can make a brand new mechanic for placing when the mouse.Target is an already placed Part
u can use mouse.TargetSurface to get the surface and then use it to get the Surface Vector after that u just set the position of the new part to the position of the part plus the Surface Vector multiplied by the GridSize.
Update, it has some very weird behaviour now. https://gyazo.com/c4fb8a250ed93c72fd76c2ac755adab1
Basically, it works for the angles that didn’t work, but now it extends it by one gridsize when it’s on the angles that did work.
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,HIT,orig,surface)
local char = script.Parent
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {char}
local dir = (HIT.Position - orig).Unit
local ray = workspace:Raycast(orig,dir*100,params)
if ray then
if mode then
local part = Instance.new("Part")
part.Name = "Placeable"
part.Material = Material
part.Color = Color
part.Transparency = Transparency
local GridSize = 3 --> Amount of studs it will move on a grid.
part.Size = Vector3.new(GridSize,GridSize,GridSize)
part.Anchored = true
local Grid = Vector3.new(math.floor(ray.Position.X/GridSize+.5)*GridSize, math.floor(ray.Position.Y/GridSize+.5)*GridSize, math.floor(ray.Position.Z/GridSize+.5)*GridSize)
part.Position = Grid
part.Parent = workspace.PartsFolders
if ray.Instance.Name == "Placeable" then
part.Position += GetVectorFromSurface(surface,ray.Instance) * GridSize
else
part.Position = Grid
end
else
if ray.Instance.Name == "Placeable" then
ray.Instance:Destroy()
end
end
end
end)
Okay, so i ended up just checking if the surface normal was either of those 3 angles, and then made the part.Position += ray.Normal * GridSize, and that worked