local Fruittilium = game.Workspace.Fruittilium local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local down = false Mouse.Button1Down:connect(function() down = true if Mouse.Target == Fruittilium then local Fruit = Fruittilium:Clone() Fruit.Parent = game.Workspace Fruit.Name = "ACOFruit" Fruit.Anchored = true Mouse.TargetFilter = Fruit while true do Fruit.Position = Vector3.new(Mouse.hit.p.x, Mouse.hit.p.y, Mouse.hit.p.z) if down == false then Fruit:Destroy() Mouse.TargetFilter = nil break end wait(.01) end end end) Mouse.Button1Up:connect(function() down = false end)
this script allows me to move objects freely.... too freely is there a way to add a grid to the object moves like one stud at a time?
The easiest way to do this is math.floor() or math.ciel()
local Fruittilium = game.Workspace.Fruittilium local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local down = false Mouse.Button1Down:connect(function() down = true if Mouse.Target == Fruittilium then local Fruit = Fruittilium:Clone() Fruit.Parent = game.Workspace Fruit.Name = "ACOFruit" Fruit.Anchored = true Mouse.TargetFilter = Fruit while true do Fruit.Position = Vector3.new(math.floor(Mouse.hit.p.x), math.floor(Mouse.hit.p.y), math.floor(Mouse.hit.p.z)) -- Adding the math.floor() will round it down to the nearest whole number therefore placing it on a stud. Unless you want it to be in the exact center in which case you would need to add or subtract 0.5 from each number. if down == false then Fruit:Destroy() Mouse.TargetFilter = nil break end wait(.01) end end end) Mouse.Button1Up:connect(function() down = false end)
Hope this helps! If you have any questions feel free to ask.