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 5 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:


--Intilaze Player's Mouse local playerMouse = game.Players.LocalPlayer:GetMouse() local pos = 0 --Tool Equipped script.Parent.Equipped:Connect(function(build) --Mouse Down Event build.Button1Down:Connect(function() print(playerMouse.hit.p) local cwb = game.Workspace.WoodBlock:Clone() cwb.Parent = game.Workspace cwb.Position = playerMouse.hit.p cwb.CFrame = cwb.CFrame + Vector3.new(0,4,0) end) end)
0
It's called a dragger man Robloxian_Hero1234 14 — 5y

1 answer

Log in to vote
0
Answered by 5 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

local Gridsize = 6
Marker.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

Grid.Position.Y + .1

My Grid Sytem

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

Answer this question