So, Im trying to make a Octopus Tentacle that plays an attack animation when it spawns. It spawns in a different spawn each time. However, when I try to get it to work, the Tentacle does not move where it should:
local plrs = game.Players:GetChildren() for i = 1, #plrs do repeat wait(1) until game.ReplicatedStorage.Texts.Value == "2:28" while wait(3) do local tentacleclone = game.ReplicatedStorage.Tentacle:Clone() tentacleclone.Parent = script.Parent local spawnpoints = script.Parent.TentacleSpawnPoints:GetChildren() local random = math.random(1,9) print(random) local randomspawn = script.Parent.TentacleSpawnPoints["SpawnPoint"..tostring(random)] print(randomspawn.Name) print(randomspawn.StartPart.Position) tentacleclone:SetPrimaryPartCFrame(CFrame.new(randomspawn.StartPart.Position)) for _, v in pairs(tentacleclone:GetChildren()) do if v:IsA("MeshPart") then v.CFrame = CFrame.Angles(math.rad(180),math.rad(-360),math.rad(180)) --math.rad is needed for radians when using CFrame.Angles end end local TweenService = game:GetService("TweenService") repeat wait(.28) local moreHeight = tentacleclone.PrimaryPart.Position local currentPosition = tentacleclone.PrimaryPart.position local goal = {} goal.Position = Vector3.new(currentPosition.X,moreHeight.Y + 25,currentPosition.Z) local tweenInfo = TweenInfo.new(1) -- add N time local tween_start = TweenService:Create(tentacleclone.PrimaryPart, tweenInfo, goal) tween_start:Play() until goal.Position.Y > randomspawn.EndPart.Position.Y local Animation = tentacleclone.Humanoid:LoadAnimation(tentacleclone:WaitForChild("Attack")) Animation:Play() Animation.Stopped:Wait() repeat wait(.28) local moreHeight = tentacleclone.PrimaryPart.Position local currentPosition = tentacleclone.PrimaryPart.position local goal = {} goal.Position = Vector3.new(currentPosition.X,moreHeight.Y - 25,currentPosition.Z) local tweenInfo = TweenInfo.new(1) -- add N time local tween_start = TweenService:Create(tentacleclone.PrimaryPart, tweenInfo, goal) tween_start:Play() until goal.Position.Y < randomspawn.StartPart.Position.Y tentacleclone:Destroy() end end
I believe my problem is coming from line 13. If something was unclear, please let me know. Thank you!