Problems with teleporting back to base

My friends and I are currently working on a lucky block based game where each player spawns in their own base. We want to make a script so when you touch a part, it’ll bring you back to your base. We have designated spawns for each player (there will be eight), and it’ll bring the player back to their assigned spawn location.

We have the script working just fine, until we use some weapons that come from our lucky blocks. Specifically ranged weapons. When there is a weapon (gun, bow, etc.) and you try to use it, The projectile would spawn far away from where the actual character is.

We aren’t really sure what the problem is. Our problem is pretty specific so as far as we know, he haven’t found any solution. We are both relatively new to scripting (my friend and I), but we would just need help as to what the problem is and maybe potential solutions.

If you need any more info to try and help, please let me know. This is the script that we have.
image

Tysm!

1 Like

I don’t know why that happens, but a better way to teleport a player is just to teleport the HumanoidRootPart like this:

character.HumanoidRootPart.CFrame = CFrame.new(workspace.Spawns.Spawn1.Position)

You can also learn more about CFrame here: CFrame | Documentation - Roblox Creator Hub

1 Like

This was extremely helpful! Tysm!

1 Like

A more simple way is to just do:

character:MoveTo(workspace.Spawns.Spawn1.Position)

Although this doesn’t incorparate orientation.

The character is a model, so you can use Model:PivotTo(), rather than moving all of the character’s parts, moving it’s root part, or using an “odd” method like MoveTo (I call it odd becuase it’s behavior can be unexpected sometimes)

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