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
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