Alright so I'm trying to make a gui button that when clicked, it inserts a model that is moved to the mouse until the player clicks to place it. Everything works so far, but I'm trying to get it to align to a stud grid of 25 studs so that everything is even. The script:
InsertId = 184711756
Player = script.Parent.Parent.Parent.Parent
Mouse = Player:GetMouse()
local Spawn = game.Workspace.Start
Clicked = false
Placed = false
function Insert()
if Clicked == true then return end
Clicked = true
Placed = false
local InsertedObject = game:GetService("InsertService"):LoadAsset(InsertId)
InsertedObject.Parent = Player.PlayerGui
local Search = InsertedObject:GetChildren()
for i = 1, #Search do
Search[i].Parent = game.Workspace.Camera
InsertedObject:Remove()
InsertedObject = Search[i]
end
InsertedObject.PrimaryPart = InsertedObject.Tile
local SB = Instance.new("SelectionBox", Player.PlayerGui)
SB.Color = BrickColor.new("Teal")
SB.Name = "Place"
SB.Adornee = InsertedObject.Tile
while Placed == false do
wait()
if (Mouse.Hit.p - Player.Character.Torso.Position).magnitude <= 100 then
if InsertedObject.Tile.Position.Y == Spawn.Position.Y then
SB.Color = BrickColor.new("Lime green")
else
SB.Color = BrickColor.new("Really red")
end
InsertedObject:MoveTo(Vector3.new(Mouse.Hit.p.X+12.5, Spawn.Position.Y, Mouse.Hit.p.Z+12.5))
else
SB.Color = BrickColor.new("Really red")
end
end
end
function Place()
if Clicked == false then return end
if Placed == true then return end
if Player.PlayerGui:findFirstChild("Place") then
if Player.PlayerGui.Place.ClassName == "SelectionBox" then
if Player.PlayerGui.Place.Color == BrickColor.new("Lime green") then
Placed = true
Clicked = false
local Search = game.Workspace.Camera:GetChildren()
for i = 1, #Search do
Search[i].Parent = game.Workspace
end
Player.PlayerGui.Place:Remove()
end
end
end
end
Mouse.Button1Down:connect(Place)
script.Parent.MouseButton1Click:connect(Insert)

1 comment
Vetex, why are you using this? I don't see any of your games with this... Oh and by the way, I use to play arcane adventures till a level 50 killed me a level 200 dude I need to know how you transfer your leaderstats to sea 2 and back and fourth from sea 1