-
What do you want to achieve? Keep it simple and clear!
I want my placement system to prevent players from placing objects outside of their plot. -
What is the issue? Include screenshots / videos if possible!
Currently im just checking the X and Z positions to make sure theyre inside their plot. But sometimes it thinks a player is placing inside their plot when they arent.
Heres my current way of checking if theyre inside their plot:
Oh yeah heres the code that converts a CFrame to object space first:
function Convert_Cf(Base, Pos, Grid, T)
local ObjPos = Base.CFrame:ToObjectSpace(Pos)
local Cf = Calc_Cf(ObjPos, Grid, T) -- Basically just converts the CFrame into a 4x4x4 grid
local WorldPos = Base.CFrame:ToWorldSpace(Cf * CFrame.Angles(0, math.rad(Current_obj.PrimaryPart.Orientation.Y), 0))
return WorldPos
end
Thought that could be helpful before we continue down the road… Now to the main code:
local Dist_X = (Current_obj.PrimaryPart.Position.X - Plot.PrimaryPart.Position.X)
local Dist_Z = (Current_obj.PrimaryPart.Position.Z- Plot.PrimaryPart.Position.Z)
if Dist_X <= 52 and Dist_X >= - 52 and Dist_Z <= 53 and Dist_Z >= - 52 then
Can_Place = true
else
Can_Place = false
end
It works. But i mean sometimes it thinks theyre inside their plot like i already said. So is there any better way of detecting this kind of stuff?. Im not the best with math so yeahhhhh…