so when i hold my mouse down, the block will move around the map however i only want the block to be moved on the x axis (left and right) of the block if the mouse is moved left or right if that makes sense. i genuinely have no idea on how to do this so i appreciate any help tysm!!
script:
local inputObject = nil
local inputBeganConnection = nil
local inputEndedConnection = nil
local loopConnection = nil
local serverPosition = nil
local raycastParams = RaycastParams.new()
local function rayCast()
local mouse = uis:GetMouseLocation()
local ray = workspace.CurrentCamera:ViewportPointToRay(mouse.X, mouse.Y)
local rayResult = workspace:Raycast(ray.Origin, ray.Direction * 100, raycastParams)
if rayResult == nil then
return ray.Origin + ray.Direction * 100
else
return rayResult.Position, rayResult.Instance
end
end
local function Loop(deltatime)
local mouse = uis:GetMouseLocation()
local position, instance = rayCast()
local yVector = Vector3.new(0,1,0)
local xVector = Vector3.new(1,0,0)
local CFrameLookAt = CFrame.lookAt(position, c:WaitForChild("HumanoidRootPart").Position)
local CFrameAngles = CFrame.new():ToEulerAnglesXYZ(0,0,0)
bigCube.CFrame = CFrameLookAt * CFrameAngles
if (position - serverPosition).Magnitude > 8 then
serverPosition = position
PositionEventAgain:FireServer(position)
end
end
vid: (credits suphi kaner for the script btw)