-
What do you want to achieve? Keep it simple and clear!
i am trying to make my own grab system for my game -
What is the issue? Include screenshots / videos if possible!
while my grab system’s AlignPosition are pretty done but, i am stuck with “Orientation”
Look Closer
FTAP:
My game’s grab system:
- What solutions have you tried so far? Did you look for solutions on the Creator Hub?
None
function ControllerMovement:Enables(Part,Attachment1,Orientation,Mode)
local oldPosition = Attachment1.Position
mouse.TargetFilter = Part
local Distance = (Part.Position - root.Position).Magnitude
MAX_DISTANCE.Value = Distance
distanceValue.Value = MAX_DISTANCE.Value
local AlignPosition = Part:FindFirstChild("AlignPosition")
local AlignOrientation = Part:FindFirstChild("AlignOrientation")
Connection = game["Run Service"].Heartbeat:Connect(function()
if root:IsA("BasePart") and root then
local attachToward = CFrame.lookAt(Attachment1.Position,root.Position)
local X,Y,Z = attachToward:ToOrientation()
AlignOrientation.CFrame = CFrame.new(AlignPosition.Position) * CFrame.Angles(X,Y,0)
end
local offset = (CFrame.new(mouse.Hit.Position)*CFrame.new(oldPosition)) .Position
Attachment1.Position = offset
if root then
local targetPos = offset
local rootPos = root.Position
local offset = targetPos - rootPos
if offset.Magnitude > MAX_DISTANCE.Value then
offset = offset.Unit * MAX_DISTANCE.Value
end
local clampedPos = rootPos + offset
AlignPosition.Position = clampedPos
end
end)
Attachment1.WorldCFrame = CFrame.lookAt(Attachment1.WorldPosition, root.Position)
end
Remember, this is not full script. i take most of parts that was related with Orientation and Position
also, Sorry for my grammar
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.