Ronan3678
(RandyMarsh)
June 26, 2021, 4:50am
#1
https://gyazo.com/d6b2731df73f745a706a006f055992d2
My grid placement system wont align with the grid, for my grid I am using a part with a decal. here is my code:
Placement:
local gymModel = workspace:FindFirstChild(player.Name…“Gym”)
local grid = workspace.GridFolder.Floor
local gridSize = 1.9
local grid = workspace.GridFolder.Floor
local Y_OFFSET = item.PrimaryPart.Size / 2
local PLACEMENT_OFFSET = Vector3.new(((grid.Size.X % 2) + 0.5) * 1.9, 0, ((grid.Size.Z % 2) + 0.5) * 1.9)
local relativePosition = Vector3.new(mouse.hit.Position.X, 0, mouse.hit.Position.Z) - grid.Position
relativePosition = Vector3.new(math.floor(relativePosition.X), Y_OFFSET, math.floor(relativePosition.Z))
local NewPos = grid.Position + relativePosition + PLACEMENT_OFFSET
local equipmentFrame = player.PlayerGui.TycoonGui.Equipment
local canPlace = false
item:SetPrimaryPartCFrame(
CFrame.new(NewPos) *
CFrame.Angles(0, math.rad(angle), 0) *
CFrame.new(1, item.PrimaryPart.Size.Y / 2, 1)
)
Grid creation incase you need it:
local gridFolder = Instance.new(“Folder”)
gridFolder.Parent = workspace
gridFolder.Name = “GridFolder”
local gridPart = part:Clone()
gridPart.Texture:Destroy()
gridPart.Size = Vector3.new(
part.Size.X,
part.Size.Y * 1.1,
part.Size.Z
)
gridPart.Transparency = 1
gridPart.Anchored = true
gridPart.CanCollide = false
local gridTexture = Instance.new("Texture")
gridTexture.Texture = "rbxassetid://5095516829"
gridTexture.Face = Enum.NormalId.Top
gridTexture.StudsPerTileU = gridPartDiameter
gridTexture.StudsPerTileV = gridPartDiameter
gridTexture.Parent = gridPart
gridPart.Parent = gridFolder
Is it possible that your system might actually work correctly, however your grid is not effectively scaled/placed correctly?
Considering trying to see if this issue persists over to a blank baseplate (the new variety) where the lines are accurately drawn out by Roblox.
Ronan3678
(RandyMarsh)
June 26, 2021, 5:21am
#3
The increment im using is 1.9 which I cant use with the roblox baseplate, also in the gif you can see it aligns perfectly when I move it to one area but when I move it again it shifts slightly more and more.
Have you tried or considered changing the increment at which it moves, in order to see if a certain increment fits the grid better?
When something only moves slightly more or less to/from the correct position, it usually means the increment is only slightly off.
Ronan3678
(RandyMarsh)
June 26, 2021, 5:42am
#5
I tested it in a baseplate with a bigger increment and you were right, any ideas on how I can fix my grid?
If you make your grid image one singular square, then you can adjust the StudsPerTile values of a Texture | Roblox Creator Documentation object! Can make it 1 stud per tile, 2 studs per tile, or anything that fits your uses!
Ronan3678
(RandyMarsh)
June 26, 2021, 6:34am
#7
I’m not sure if that is the problem I adjusted the studs per tile but it still isnt aligned
Your grid is snapping properly it’s just in your gif I think you have a decal with the grid 2 studs squared. That probably explains it being placed unevenly on most studs but works every so often. Because your grid snaps to 1.9 on the decal it should snap properly every 10 studs, try changing the grid size to 2 or the stud size on the decal to 1.9
Ronan3678
(RandyMarsh)
June 26, 2021, 7:03am
#9
I tried doing both but I still get the same result
Ronan3678
(RandyMarsh)
June 26, 2021, 7:06am
#10
Here is my code for the grid:
function Grid.createGrid(gridSizeX, gridSizeZ, gridPartDiameter, gridStartPosX, gridStartPosZ,part)
local gridFolder = Instance.new(“Folder”)
gridFolder.Parent = workspace
gridFolder.Name = “GridFolder”
local gridPart = part:Clone()
gridPart.Texture:Destroy()
gridPart.Size = Vector3.new(
part.Size.X,
part.Size.Y * 1.1,
part.Size.Z
)
gridPart.Transparency = 1
gridPart.Anchored = true
gridPart.CanCollide = false
local gridTexture = Instance.new("Texture")
gridTexture.Texture = "rbxassetid://5095516829"
gridTexture.Face = Enum.NormalId.Top
gridTexture.StudsPerTileU = gridPartDiameter
gridTexture.StudsPerTileV = gridPartDiameter
gridTexture.Parent = gridPart
gridPart.Parent = gridFolder
end
Could you format all of the code? It’s pretty hard to read
Ronan3678
(RandyMarsh)
June 26, 2021, 7:17am
#12
Ronan3678
(RandyMarsh)
June 27, 2021, 12:48am
#13
anyone that had the same problem as me I found out that it was in fact my grid that was causing the problem what you need to do is make sure that the part that you use for your grid x and z axis are even and divisible by the grid size you want