Boss charging at Player

I want to preface this as I did in a previous post by saying that I’m using the code from “How to make a Boss Fight” video series made by NoobieYT (Code created by Luascripts) in the pursuit of studying and understanding it.

When the boss does its charge attack, it takes the player’s position, charges and stops at that exact position. What I want to do is to make it to where the boss goes past the player instead of stopping at the player’s position.

This is what I want to happen.

Here’s the module for the Charge:

module.Charge = function(Player, BossHumanoidRootPart, BossHumanoid)
	local PlayerFound = table.find(AttackedPlayersArray, Player.Name)
	if not PlayerFound then
		table.insert(AttackedPlayersArray, PlayerIndexCount, Player.Name)
		PlayerIndexCount += 1
	end
	local Beam = game:GetService("ServerStorage").Arrows:Clone()
	Beam.Parent = workspace
	local Attachment0 = game:GetService("ServerStorage").Attachment0:Clone()
	Attachment0.Parent = workspace
	local Attachment1 = game:GetService("ServerStorage").Attachment1:Clone()
	local PlayerPosition = Player:FindFirstChild("HumanoidRootPart").Position
	local PlayerCFrame = Player:FindFirstChild("HumanoidRootPart").CFrame
	local LoadRollingAnimation = BossHumanoid:LoadAnimation(AnimationsFolder.Rolling)
	Attachment1.Parent = workspace
	Beam.Attachment0 = Attachment0.Attachment0
	Beam.Attachment1 = Attachment1.Attachment1
	Attachment0.Position = BossHumanoidRootPart.Position - Vector3.new(0, 6, 0) -- Attach Attachments to Player and Boss
	Attachment1.Position = PlayerPosition - Vector3.new(0, 2, 0)
	Beam.FaceCamera = true
	Attachment0.Orientation = Vector3.new(0, 0, 90) + BossHumanoidRootPart.Position
	Attachment1.Orientation = Vector3.new(0, 0, 90) + PlayerPosition
	game.Debris:AddItem(Attachment0, 0.5)
	game.Debris:AddItem(Attachment1, 0.5)
	game.Debris:AddItem(Beam, 0.5)
	task.wait(0.5)
	TweenService:Create(BossHumanoidRootPart, TweenInfo.new((PlayerPosition + Vector3.new(0, 3, 0) - BossHumanoidRootPart.Position).Magnitude / 100), {CFrame = PlayerCFrame * CFrame.new(0, 3, 0)}):Play()
	LoadRollingAnimation:Play()
	local RollingSound = SoundsFolder.RocksRolling:Clone()
	RollingSound.Parent = BossHumanoidRootPart
	RollingSound:Play()
	game.Debris:AddItem(RollingSound, RollingSound.TimeLength)
	task.wait((PlayerPosition + Vector3.new(0, 3, 0) - BossHumanoidRootPart.Position).Magnitude / 100)
	LoadRollingAnimation:Stop()
	module.RockDebree(BossHumanoidRootPart.Position, 5)
end

I think I have to edit the TweenInfo to accomplish this, although I’m not sure. I did a little troubleshooting with it. Any push in the right direction to accomplish this?

I’m pretty sure you could just fix this by setting the position the boss is charging to (the player’s position) just slightly higher by simply just multiplying it by a number or something, like 1.1 to make them overshoot by 10%. I don’t know exactly if this would work but I think this is the general direction you would want to head in fixing this problem.

1 Like

Instead of PlayerCFrame * CFrame.new(0, 3, 0) try with PlayerCFrame * CFrame.new(0, 3, 15) , this will make it so the tween will transport the boss 15 studs behind the player.

2 Likes

Is it possible to multiply positions? I was trying it the first time I was troubleshooting although I’m not sure how that would work.

Thank you! I didn’t realize that CFrame was where I should of been changing the values of. Although it makes sense now that I think about it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.