Laser beam attack help

Hello!

I have been trying to make a laser beam attack, A laser that tweens out basically. However, the rotation of the laser doesnt match the players rotation. Like instead of facing the same direction the player is facing its facing 90 degrees to the right instead, also the animation isn’t right. I have looked this up on Youtube and devforum but they all say to use BodyVelocity, which doesn’t stretch the laser

How the laser is supposed to spawn:
image

How it actually spawns:
image
How the animation supposed to look like:
image
How it looks:
image

local TS = game:GetService("TweenService")
local fireing = false
script.Parent.OnServerEvent:Connect(function(plr,hit)
	if fireing == false then
		fireing = true
	local orbs = script.Parent.Parent.Parent.Parent.Orb:Clone()
	
	orbs.Parent = plr.Character:WaitForChild("HumanoidRootPart")
	orbs.Position = plr.Character:WaitForChild("HumanoidRootPart").Position
	local laser = game.ReplicatedStorage.laser:Clone()
	wait(0.5)
	local weldForLaser = Instance.new("Weld")
	weldForLaser.Parent = laser
	weldForLaser.Part0 = laser
	weldForLaser.Part1	= orbs
	laser.Parent = plr.Character:WaitForChild("HumanoidRootPart")
	wait(0.1)
	local weld = Instance.new("Weld")
	orbs.Parent = plr.Character:WaitForChild("HumanoidRootPart")
	orbs.Anchored = false
	weld.Parent = orbs
	weld.Part0 = orbs
	weld.Part1 = plr.Character:WaitForChild("HumanoidRootPart")
	wait(0.1)
	plr.Character:WaitForChild("HumanoidRootPart").Anchored = true
	orbs.a1.RoughSwishThing.Rate = 4.5
	wait(0.3)
	orbs.a2.RoughSwishThing.Rate = 4.5
	wait(0.3)
	orbs.a3.RoughSwishThing.Rate = 4.5
	wait(0.3)
	orbs.a4.RoughSwishThing.Rate = 4.5
	wait(0.3)
	orbs.a5.RoughSwishThing.Rate = 4.5
		wait(0.5)
	
	laser.Transparency = 1
	laser.Anchored = false
		wait(0.1)
		laser.Rotation = Vector3.new(0,90,0)
	TS:Create(laser, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Size = Vector3.new(71,4,4)}):Play()
	wait(1)
	TS:Create(laser, TweenInfo.new(0.15), {Transparency = 0}):Play()
	wait(0.2)
	laser:Destroy()
	plr.Character:WaitForChild("HumanoidRootPart").Anchored = false
	wait(0.3)
	orbs.a1.RoughSwishThing.Rate = 0
	
	orbs.a2.RoughSwishThing.Rate = 0
	
	orbs.a3.RoughSwishThing.Rate = 0

	orbs.a4.RoughSwishThing.Rate = 0

	orbs.a5.RoughSwishThing.Rate = 0
	wait(0.3)
		orbs:Destroy()	
		fireing = false
	end
end)

here is the code:

Thanks for helping!

5 Likes

Though I’m still new to the Forum and scripting in general, I could give a hand.

Instead of using the Position of the HumanoidRootPart, use the CFrame instead. After that, use CFrame.Angles() (At least, I think that’s what it was called) to multiply to the CFrame and rotate to your liking afterwards, if the beam already doesn’t fit to your liking.

Hope this helps!

ok thank you! ill try this out

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