Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Movin Block Like In A Grid Can Someone Help me?

Asked by 6 years ago

I made a build tool for my game, But I tried to moving stud to stud. (When I click some here,I want to part move like to colliding to 4 stud grid.)

Here's Code:

01  --Intilaze Player's Mouse
02  local playerMouse = game.Players.LocalPlayer:GetMouse()
03  local pos = 0
04 
05 
06  --Tool Equipped
07script.Parent.Equipped:Connect(function(build)
08    --Mouse Down Event
09    build.Button1Down:Connect(function()
10 
11        print(playerMouse.hit.p)
12 
13 
14        local cwb = game.Workspace.WoodBlock:Clone()
15 
View all 33 lines...
0
It's called a dragger man Robloxian_Hero1234 14 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Well its actually more complicated you would have to use math.floor

im actually attempting something like this myself and ive spent 4 days on it already its part of my game

So the snapping would be like

1local Gridsize = 6
2Marker.CFrame = CFrame.new((math.floor(mouse.Hit.X / GridSize +.5 ) * GridSize), Grid.Position.Y + .1, (math.floor(mouse.Hit.Z / GridSize ) * GridSize))

In my case i was making a floor for the grid system so i did

1Grid.Position.Y + .1

My Grid Sytem

0
Thanks! Infi_power -9 — 6y
0
And I fixed my Issue about placing blocks with Ray Operation with your snapping formula :) Infi_power -9 — 5y
Ad

Answer this question