Kinda hard to explain, but here goes nothing. So what I have is a module, RenderPosition, which I use to set the position of a part based on the mouses position. I have 2 modules, one for placing walls, one for placing objects. Now, starting with walls, the RenderPosition works well for placing the walls. However, with object placing, since it is a model instead of a part means this RenderPosition doesn’t work.
RenderPosition Module
return function(playersPlot, mouseP, object, lowerX, upperX, lowerZ, upperZ)
local mouseClampedP = clampMouse(mouseP, lowerX, upperX, lowerZ, upperZ)
object.CFrame = CFrame.new(round(mouseClampedP + Vector3.new(0, object.Size.X/2, 0), gridSize, playersPlot.Base.Position.Y + (object.Size.X/2) + 0.05))*CFrame.Angles(0, 0, math.rad(90))
end
DrawWall Module
pole1 is a single part
renderStepped = runService.RenderStepped:Connect(function()
renderPosition(playersPlot, mouse.Hit.p, pole1, lowerX, upperX, lowerZ, upperZ)
end)
PlaceObject Module
item is a model, with a PrimaryPart being like it’s hitbox
renderStepped = runService.RenderStepped:Connect(function()
renderPosition(playersPlot, mouse.Hit.p, item, lowerX, upperX, lowerZ, upperZ)
end)
I really don’t wanna have 2 seperate modules to basically do the same thing. So is there anyway to get this is work for both modules. To also note, I can’t set a PrimaryPart for the wall one, as it would ruin the functionality, so something would have to change in the object placement module, but Idk what