Move model to mouse in studs?
I made a script that when you click a GUI button, it will clone an object and allow you to place it somewhere. The script works, the object follows the mouse until clicked again and then is placed where it needs to be, however I need it to move like a grid such as like miners haven.
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 | local objects = game.ReplicatedStorage.Objects |
05 | local ob = script.Parent.Object |
06 | script.Parent.MouseButton 1 Click:connect( function () |
07 | if debounce = = false then |
09 | part = objects:FindFirstChild(ob.Value) |
11 | part.Position = Vector 3. new( 0 , 0 , 0 ) |
14 | clone.Parent = game.Workspace |
15 | local owner = Instance.new( "StringValue" , clone) |
17 | owner.Value = game.Players.LocalPlayer.Name |
18 | local object = Instance.new( "StringValue" , clone) |
19 | object.Name = "Object" |
20 | object.Value = script.Parent.Object.Value |
25 | if debounce = = true then |
26 | local posX,posY,posZ = mouse.hit.X, mouse.hit.Y, mouse.hit.Z |
27 | clone.Position = Vector 3. new(posX,posY,posZ) |
30 | mouse.Move:connect(mouseMove) |
32 | mouse.Button 1 Down:connect( function () |
33 | if debounce = = true then |
Any help would be appreciated. -Wizy