I want to make the attachment in change purple move from RockPart 1 to the end and eventually hit the player at the end.
How can I make it so that it can move through all these parts sequentially.
RockScript:
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local CraterModule = require(script.Parent:WaitForChild("CraterModule"))
local PartSize = Vector3.new(1, 1, 1)
local PartSpacing = 5
local Purple = script.purple.Attachment
local function CreateParallelParts(OriginPosition, AmountOfParts, LookVector)
local Character = Players.LocalPlayer.Character
local HumanoidRootPart = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
local PigmaAnimation = Humanoid.Animator:LoadAnimation(script.PigmaAnimation)
PigmaAnimation:Play()
for i = 1, AmountOfParts do
local Part = workspace.RockPart:Clone()
Part.Size = PartSize
Part.Anchored = true
--local PurpleClone = Purple:Clone()
--PurpleClone.Parent = Part
Part.Parent = workspace.CoreObjects.CraterRocks
if i % 2 == 0 then
Part.CFrame = OriginPosition * CFrame.new(Vector3.new(0, 0, -PartSpacing * i)) * CFrame.new(Vector3.new(5, -5, 0))
else
Part.CFrame = OriginPosition * CFrame.new(-Vector3.new(0, 0, PartSpacing * i)) * CFrame.new(Vector3.new(-5, -5, 0))
end
TweenService:Create(Part, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.In), {CFrame = Part.CFrame * CFrame.new(0, 5, 0)}):Play()
local RayResult = workspace:Raycast(Part.Position + Vector3.new(0, 10, 0), Vector3.new(0, -100, 0))
if RayResult then
local Position = (Part.Position + RayResult.Position) / 2
CraterModule.CreateCrater(Position, 7, 3.5, 0.9, 0.3)
end
Debris:AddItem(Part, 0.8)
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.R then
local player = Players.LocalPlayer
local character = player.Character
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local OriginPosition = HumanoidRootPart.CFrame
local AmountOfParts = 5
local LookVector = (OriginPosition.Position - HumanoidRootPart.Position).Unit
CreateParallelParts(OriginPosition, AmountOfParts, LookVector)
end
end)