Teleport move makes you teleport into walls

In my game I have a move that makes you teleport a short distance in front of you, however if you are facing a wall, sometimes, if not most of the time it teleports you into the wall.

I didn’t use raycasting because I want this move to go through and damage players, and a ray will just stop at a player. I made a projectile that goes through players and should anchor when it touches a wall but half of the time it doesn’t.

This is what it looks like

Using a bodyvelocity and a bodyposition have no difference in result

This script is a LocalScript

local anim = char.Humanoid:LoadAnimation(script.Teleport)
local part ="Part")
part.Size =,1,1)
part.Transparency = 1
part.CanCollide = false
part.Massless = true

	part.Parent = workspace
	part.CFrame = char.HumanoidRootPart.CFrame *,0,0)
	local BV ="BodyVelocity",part)
	BV.MaxForce =,10000,10000)
	BV.Velocity = char.HumanoidRootPart.CFrame.LookVector * 600

if hit.Parent:FindFirstChild("Humanoid") == nil and hit.Parent.Parent:FindFirstChild("Humanoid") == nil and hit.CanCollide == true then
	part.Anchored = true

		game.ReplicatedStorage.RemoteEvents.Attacks.Teleport:FireServer(char.HumanoidRootPart.Position) --- this isn't relevant to the problem
		part.Anchored = true
		char.HumanoidRootPart.CFrame = part.CFrame
1 Like

You should try testing if there is a collision at the position the player is going to teleport to. This means that if the player can teleport far enough to go through the wall, but not end up in the wall, it will still let them, but if their final position is in the wall, you can restrict it.

It does teleport you through the wall if the wall is thin, and I don’t want that either. If the wall is really thick, it will teleport you into the wall

I think you should use raycasting. You can use raycasting to check if the part is a wall and the maybe make the body velocity a little bit smaller in power.

The problem with raycasting is that it will stop at anything, even a part that has cancollide set to false, and I don’t want that, and I also don’t want to label every individual part that has cancollide set to false so that I can add it to the ignore list

I’m pretty sure you can set raycasts to ignore certain things.

You can detect if a a raycast result is has can collide set to false or true.

the ray will still stop at that part though, which is why I didn’t use raycasting

Those things have to be put in a table, and you can’t put an if statement in a table

If you want to go the simple way, just put another wall inside of the wall. I think this will work, tell me if I am wrong.

That way player’s can’t see the outside.

This may be of assistance.

The thing with that is that I have mulitple maps, and I would have to go through each individual map to do that. In short, that would be very tedious. If raycasting really is a solution, I’d like to know how to make parts that have cancollide set to false not stop a ray

Is it need to have shift lock? Or can you permanently disable it?

Yes, my game does require shift lock in order to be functional. Why do you ask?

I asked because the way you looked outside of the wall was by using shift lock.

Oh I solved that problem a while ago. I added layers of walls to prevent players from looking outside

What is the location of this script? And also did the print work?

Then, when it stops check if the part has collissions off, if it does add it to a table and do the ray cast again. Repeat until it finds a non-collidable part and then compare the distance to see if it is avaiable.

I think I found the problem. You are using the touched event in a local script. Use a remote event to use the touched event. Also this is highly exploitable the player can teleport themselves basically where ever they want.