Ello. Been working on omni directional maneuver gear (odmg or 3dmg) from attack on titan. Everything is going great! Got the camera to work, the hooks, turning, everything in the module is ready to be used. There is one thing im stuck on. Before the hook finished tweening, i send out a ray. It works fine, gets the postition and instance and everything. However, i want the hook to attach to a part where the ray intersected the part. I am able to do that. However I want the anchor to move when the basepart it is attached to moves. How would i go about doing this? My current hook function if needed located below, and the hooks work but flings around and stuff.
if side == 'Right' then
if not self.Variables.RightActive then
local connection
self.Variables.RightActive = true
local Anchor = game.ReplicatedStorage.Hook:Clone()
Anchor.Parent = self.Character.Hooks
Anchor.Position = self.RightGear.PrimaryPart.Position
Anchor.Name = 'Right'
local Beam = script.Beam:Clone()
Beam.Parent = Anchor
local att1 = Instance.new("Attachment", Anchor)
local att2 = Instance.new("Attachment", self.Character.RightGear.PrimaryPart)
Beam.Attachment0 = att1
Beam.Attachment1 = att2
local Time = (position - Anchor.Position).Magnitude/600
local tween = tws:Create(Anchor, TweenInfo.new(Time), {Position = position})
tween:Play()
local rayP = RaycastParams.new()
rayP.FilterType = Enum.RaycastFilterType.Blacklist
rayP.FilterDescendantsInstances = {self.Character}
local ray = workspace:Raycast(self.Character.LeftGear.PrimaryPart.Position, (position - self.LeftGear.PrimaryPart.Position).Unit * 400, rayP)
local at1 = Instance.new('Attachment')
local at2 = Instance.new('Attachment')
local logged
if self.Variables.RightActive then
tween.Completed:Connect(function()
Anchor.Anchored = false
if ray then
logged = ray.Position
print('ray hit: '..ray.Instance.Name)
at1.Parent = Anchor
at2.Parent = ray.Instance
at2.Position = CFrame.new(position):ToObjectSpace(ray.Instance.CFrame)--error here, 'Unable to assign property Position. Vector3 expected, got CFrame' i just need it to position it on the part where it intersected and move when the part moves
local hinge = Instance.new('HingeConstraint', Anchor)
hinge.Attachment1 = at1
hinge.Attachment0 = at2
end
if self.Variables.RightActive then
self.BodyVelocity.Parent = self.Character.HumanoidRootPart
self.BodyGyro.Parent = self.Character.HumanoidRootPart
connection = runservice.Heartbeat:Connect(function()
if self.Variables.RightActive == true then
print('Running')
self.BodyVelocity.MaxForce = self.Variables.Force
local target = CFrame.lookAt(self.Character.HumanoidRootPart.Position, Anchor.Position)
self.BodyVelocity.Velocity = (-target.ZVector * self.Variables.Speed)
self.BodyGyro.CFrame = CFrame.new(self.Character.HumanoidRootPart.Position, Anchor.Position)
else
pcall(function()
connection:Disconnect()
Anchor:Destroy() Beam:Destroy() att1:Destroy() att2:Destroy() self.BodyVelocity.Parent = self.Character self.BodyGyro.Parent = self.Character
end)
end
end)
else
Anchor:Destroy() Beam:Destroy() att1:Destroy() att2:Destroy()
if self.Character.HumanoidRootPart:FindFirstChild("BodyVelocity") then
self.Character.HumanoidRootPart.BodyVelocity.Parent = self.Character
end
if self.Character.HumanoidRootPart:FindFirstChild("BodyGyro") then
self.Character.HumanoidRootPart.BodyGyro.Parent = self.Character
end
end
end)
else
Anchor:Destroy() Beam:Destroy() att1:Destroy() att2:Destroy()
if self.Character.HumanoidRootPart:FindFirstChild("BodyVelocity") then
self.Character.HumanoidRootPart.BodyVelocity.Parent = self.Character
end
if self.Character.HumanoidRootPart:FindFirstChild("BodyGyro") then
self.Character.HumanoidRootPart.BodyGyro.Parent = self.Character
end
end
end
end