Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Simple teleportation code not working?

I have this code that should teleport you, but it doesn't work. Filtering enabled is on, and it's in a serverscript. No errors in output. Code:

local user = workspace:FindFirstChild(game.ReplicatedStorage.player.Value --this is set to the name of the player)

wait(4)
user:FindFirstChild("HumanoidRootPart").CFrame = Vector3.new(-552.069458, 168.347977, -593.177063)

What's wrong?

6 comments

0

I have to mention I have team create on!

0

make a variable for "workspace" lol?

0

workspace is short for "game.Workspace" and it's a real thing...

0

why would he make a variable for workspace? i dont get it

0

Wow, I never knew you could do "workspace".

0

In this code you never defined user; what's user?

2 answers

The way you teleported the HumanoidRootPart is incorrect I think. I think it should be something like this:

user:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(0,13,0)) -- This will teleport the player up.

Change FindFirstChild() to WaitForChild(). This will make the script wait for the HumanoidRootPart to exist, since scripts run earlier before the character of the player even gets into the game.

2 comments

0

If it still doesn't work, probably something to do with FilteringEnabled?

0

Stillll doesn't work...

try this

local user = workspace:FindFirstChild(game.ReplicatedStorage.player.Value --this is set to the name of the player)

wait(4)
user:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(-552.069458, 168.347977, -593.177063)

23 comments

0

u copy me answer ;-; also doing that will probably make the character into the floor. (If there's a floor) So you need to add more value on the Y.

0

no i did not? you put a vector3 inside?

0

Also, you don't know where he is trying to teleport his character to, if he wants to bring his character model higher, he can just add +5 or so to the Y value

0

Yea, I was just saying that if he is trying to teleport the player, and if he is teleporting the character to a part, the character will end up teleporting inside the part. Because it will teleport the player to the exact position that you just wrote

0

Yes this will put the humanoidrootpart directly at that position, but again we don't know if he has or has not yet accounted for that.

0

Ok, for some reason this STILL wont work... don't know why D: . Also, this teleports you to a floating part that has CanCollide off

0

Are you positive that user, is actually getting the player? try printing it to see if it is what you actually think it is

0

Maybe something to do with whether you are using R6 or R15?

0

It shouldnt be that, both R6 and R15 have HumanoidRootParts

0

MakeYourEscape, can you elaborate on what is inside of the 'player' that is inside of ReplicatedStorage?

0

I think I know what's wrong, do WaitForChild() instead of FindFirstChild() maybe the HumanoidRootPart didn't exist when the script was looking for it?

0

Because scripts run earlier before the character even gets into the game.

0

Actually, you are kind of right, if this script is running right when the game starts, it probably wont find the 'player.Value' in replicated storage

0

Change the first FindFirstChild on line 1 to WaitForChild(), i think the wait(4) should be enough time that you dont have to change the second one though

0

You don't need to the wait() anymore, you can just remove it because the script will wait for the HumanoidRootPart to exist.

0

again, we don't know his intentions. He may want the players to wait 4 seconds. I wish he would respond :F

0

Lol Ikr XDDD, anyways. Happy to help! I have to go now. Goodbye.

0

If Escape just copy pasted your whole script, it’s probably not working because you commented out a parenthesis on line 1, leaving one parenthesis only and making an error. Just put the comment outside of the parentheses. :P

0

lol, that was just a copy and paste from his original question.

0

Oh, pff. I didn’t notice that. Well, we’ll probably need to tell Escape about that.

0

yea, i think he fell off the earth tho :(

0

I fell off Earth and went to Mars, sorry!

0

Okay, I found the reason why it wasn't working was because of a whole bunch of other scripts that were doing things I thought I fixed. Thanks for the help.

This discussion is preserved as it was. New answers, comments, and votes are closed.