Characters not teleporting to desired area

Hey guys, so im trying to make a “Domain Expansion” from Jujutsu Kaisen.
[I’m taking a lot of inspiration from a game called Jujutsu Shenanigans to make the stuff tbh]

But my problem is that when i try to teleport the players/npcs to the area, these just don’t teleport and stay in the same place they were.
I put the players that got hit by a hitbox [GetPartBoundsInRadius] on a table

local PlayersHit = {}
	local Hitbox = workspace:GetPartBoundsInRadius(RootPart.Position, Range, Params)
	for i,Part in pairs(Hitbox) do
		if Part.Parent:FindFirstChild("Humanoid") and not table.find(PlayersHit, Part.Parent) then
			table.insert(PlayersHit, Part.Parent)
			local Enemy = Part.Parent			
			local EnemyHumanoid = Enemy:FindFirstChild("Humanoid")
			local EnemyPlr = Players:FindFirstChild(Enemy.Name)
				
				EnemyHumanoid.WalkSpeed = 0
				EnemyHumanoid.JumpPower = 0

				if EnemyPlr then
					PropagandaRemote:FireClient(EnemyPlr, "Whiteout", 3.2)
					PropagandaRemote:FireClient(EnemyPlr, "Theme", "Limitless", "Play")
					PropagandaRemote:FireClient(EnemyPlr, "FOV", 120, 3.6)
				end		
			print(PlayersHit)

		end
	end	

And then i use the table to teleport them.

for _, Char in pairs(PlayersHit) do
		
		local EnemyHumanoid = Char:FindFirstChild("Humanoid")
		local EnemyRoot = Char:WaitForChild("HumanoidRootPart")
		
		local Magnitude =  RootPart.Position - EnemyRoot.Position 
		Char:MoveTo(AreaClone.UserSpawn.Position - Magnitude) 
		
		print("Teleported ".. Char.Name)
		
		task.wait()

		EnemyHumanoid.WalkSpeed = 16
		EnemyHumanoid.JumpPower = 50
		
		local EnemyPlr = Players:FindFirstChild(Char.Name)
		if EnemyPlr then
			PropagandaRemote:FireClient(EnemyPlr, "No Whiteout", 2)
			PropagandaRemote:FireClient(EnemyPlr, "FOV", "Normal", 2)
		end			
	end

Idk what’s the problem, i don’t get any errors in console
I already tried by changing HumanoidRootPart’s CFrame and didn’t work either
Everything happens on a ModuleScript that get’s called from a Server Script

Proof on Studio

Hello!

local Hitbox = workspace:GetPartBoundsInRadius(RootPart.Position, Range, Params)

Hmm can you confirm that Hitbox does have player parts inside of the table and is not empty?
Perhaps add a print(Hitbox) after the line

Tips use print statements starting from the beginning all the way to end to figure if some logic is wrong in the script.

print("Teleported ".. Char.Name)

Does this print?

2 Likes

Hi, thanks for answering.
Yeah, i got a print(Hitbox) on the code and it prints all the characters
The teleported one prints too

1 Like

Hi again
When calculating magnitude you need to add .magnitude at the end so like this

local Magnitude = (RootPart.Position - EnemyRoot.Position).Magnitude 

Maybe this will work, if not lmk!

(Edit)
Oh wait that will not work because it will turn into a number.
I believe :MoveTo requires you to use the humanoid rather then the character, so maybe try

Char.Humanoid:MoveTo()
1 Like

Wait nvm, could you try to print the location they get teleported to, and see if its correct?

1 Like

Hi
Yeah, it prints it correctly.
Idk what’s happening tbh
Somehow im the only one getting teleported correctly, i even tried with some friends to check if it’s a Dummy thing but they don’t get teleported too, just sometimes…

I feel I have experienced this in the past too strangely. I think the moveto: function is broken (Could be wrong) or something. I think the solution would be to move the characters with CFrame, thats atleast what I do now. Downsides with that is I believe the moveto will teleport the character on top of a part if they get teleproted inside the part. But if your teleporting them somewhere open it should be fine. What you can do is this

Char.HumanoidRootPart.CFrame = CFrame.new(AreaClone.UserSpawn.Position - Magnitude) 

Instead of

Char:MoveTo(AreaClone.UserSpawn.Position - Magnitude) 
1 Like

The problem persists, tried moving with CFrame before trying with :MoveTo()
Also tried moving the entire character with :PivotTo(). Didn’t work either

Idk what to do at this point tbh

BRUHH
I tried using a part on the middle of the sphere instead of my HumanoidRootPart and now it works perfectly fine :skull:

Anyways, thank you so much for helping me dude.
Very thankful!

1 Like

Hahaha we all make silly mistakes dw, it was my pleasure helping. Glad you got it work!

1 Like

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