My Beam doesnt CFrame to HumanoidRootPart

  1. What do you want to achieve? I want to make this GasterBlaster/Beam zone, and make it work kinda like this


    (that but in a zone)

  2. What is the issue? I made the zone using ZonePlus but i cant make it so the blaster spawns infront of the player, its spawns only infront of the zone container


    and not infront of the player

code :

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoidRootPart = character:WaitForChild('HumanoidRootPart')
		
		local debounce = false
		
		local zone = require(game.ReplicatedStorage.Zone)
		local container = workspace.Container
		local zone = zone.new(container)
		
local inZone = false
zone.playerExited:Connect(function(player)
	inZone = false
end)

zone.playerEntered:Connect(function(player)
	if (inZone) then
		return
	end
	inZone = true
	
	while (inZone) do
		local modelpositionpart = Instance.new('Part')
					modelpositionpart.Massless = true
					modelpositionpart.CanCollide = false
					modelpositionpart.Transparency = 1
					modelpositionpart.Parent = humanoidRootPart
					modelpositionpart.CFrame = CFrame.new(humanoidRootPart.Position.X,humanoidRootPart.Position.Y+1.5,humanoidRootPart.Position.Z-30) * CFrame.Angles(math.rad(180),0,3.15)

					local weldconstraint = Instance.new('WeldConstraint')
					weldconstraint.Parent = humanoidRootPart
					weldconstraint.Part0 = humanoidRootPart
					weldconstraint.Part1 = modelpositionpart


						local model = game:GetService('ServerStorage'):WaitForChild('Blaster'):Clone()
						model.Parent = workspace
						model:SetPrimaryPartCFrame(modelpositionpart.CFrame)
						wait(3.8)
						model:Destroy()
					if (debounce == true)  then 
						return end

					wait(2)
					debounce = false
			end	
		end)
	end)
end)

the issue is in this part of the code

local model = game:GetService('ServerStorage'):WaitForChild('Blaster'):Clone()
						model.Parent = workspace
						model:SetPrimaryPartCFrame(modelpositionpart.CFrame)
						wait(3.8)
						model:Destroy()
					if (debounce == true)  then 
						return end

my old code used to have a repeat loop in that part and that made the code aim at the HumanoidRootPart but i deleted it since it made my code break and kept executing after i left the zone

i have no idea of what to do, help!

try setting the primarypart cframe to something like this:

local distance = 10
local pos = root.Position + root.CFrame.LookVector * distance
local cframe = CFrame.new(
pos, --The origin
root.Position, -- The position the cframe needs to face
)

wait wait hold up, can u tell me where do i put this code?, sorry im still a rookie and i didnt quite understand :sweat_smile:

Dont use a weldConstraint, use a modelpositionpart, set it to the players head and then set the beam to the modelpositionpart.