Projectile not spawning in the correct position after player teleports

Hi, recently I came a cross a problem that i cant seem to find a solution. Im trying to make a dodgeball script so that whenever the player clicks, the ball shoots out in the direction of the player’s mouse. It works as predicted when the player joins the game, but after I teleport the player to a map, the ball does not shoot out anymore and disappears. The ball still appears in the explorer, so i think that the ball might be spawning in the wrong place after the player teleports
Code below:

local debris = game:GetService("Debris")
script.Parent.RemoteFire.OnServerEvent:Connect(function(plr,lookat)
	local ball = script.Parent.Handle
	ball.Parent = workspace
	ball:SetAttribute("Player",plr.Name)
	ball.CFrame = CFrame.new(ball.Position,lookat)
	ball.Velocity = ball.Velocity + ball.CFrame.LookVector*200
	wait(0.1)
	ball.CanCollide = true
	local touchconn
	touchconn = ball.Touched:Connect(function(hit)
		ball.Script.Disabled = false
		print("Enabled")
		local cd = Instance.new("ClickDetector",ball)
		touchconn:Disconnect()
		script.Parent:Destroy()
		
	end)
	debris:AddItem(script.Parent,10)
end)

This is the serverside code.
I tried a few ways to solve it such as setting the position of the ball to the player’s arm, but nothing seems to work.
Also, there are other projects i made that have encountered this issue, such as gun bullets not spawning in the correct place after teleportation.
Please help! thx

You aren’t setting the ball’s position to the player tho, you’re just doing:

ball.CFrame = CFrame.new(ball.Position,lookat)

which doesn’t set the position to the character. Maybe change it to this line:

ball.CFrame = CFrame.new(Player.Character.LeftHand.Position, lookat) -- change LeftHand to whatever limb you want the ball to go

I tried it, but it still doesnt work tho :confused:

Solved it. For some reason the position of the limbs and the ball does not move accordingly when i teleport the humanoid root part. Setting the position of the ball to the humanoid root part and offsetting it so it appears near the hand worked.