You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to make a part, whos position is determined by the mousepos(x and z) to move say every half stud, instead of the very precise position of the mouse. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Documentation, Youtube, just trying it.
Script:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screenGui = script.Parent
local rep = game:GetService("ReplicatedStorage")
local stored = rep.StoredParts
local UIS = game:GetService("UserInputService")
-------------------------------------------viewport
screenGui.Parent = playerGui
local viewportFrame = script.Parent.ViewportFrame
local part1 = game.ReplicatedStorage.StoredParts.part1:Clone()
part1.Parent = viewportFrame
local viewportCamera = Instance.new("Camera")
viewportCamera.Name = "Display"
viewportCamera.Parent = script.Parent
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.CFrame = CFrame.new(Vector3.new(0, 2, 5), part1.Position)
-------------------------------------------on/off
local part1b = script.Parent.ViewportFrame.part1
local db = true
local partinquestion
local Orientation = Vector3.new(0,0,0)
part1b.MouseButton1Click:Connect(function()
if db == false then
partinquestion = stored[part1b.Name]
part1b.Text = "Selected"
if partinquestion then
local ghost = partinquestion:Clone()
ghost.Name = player.Name
ghost.Parent = workspace.Ghosts
ghost.Anchored = true
ghost.CanCollide = false
-------------------------------------------UIS for rotation
UIS.InputBegan:Connect(function(input, gamePro)
if input.KeyCode == Enum.KeyCode.R then
print("r")
Orientation = Orientation + Vector3.new(0,90,0)
rep.Events.Rotate:FireServer(Orientation)
ghost.Orientation = Orientation
elseif input.KeyCode == Enum.KeyCode.Q then
print("q")
Orientation = Orientation + Vector3.new(0,-90,0)
rep.Events.Rotate:FireServer(Orientation)
ghost.Orientation = Orientation
end
end)
local mouse = player:GetMouse()
mouse.TargetFilter = ghost
mouse.Move:Connect(function(L)
local mousepos = mouse.hit
ghost.Position = Vector3.new(mousepos.X,0,mousepos.Z)
end)
end
db = true
else
db = false
part1b.Text = ""
if game.Workspace.Ghosts[player.Name] then
local ghost = game.Workspace.Ghosts:FindFirstChild(player.Name)
ghost:Destroy()
end
end
end)
-------------------------------------------placing
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function(G)
if db == true then
if partinquestion then
local mousep = mouse.Hit.Position
rep.Events.Place:FireServer(partinquestion, mousep, Orientation)
end
end
end)
-------------------------------------------grid
--tbd
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.