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

How do I make the player or client teleport?

teleportpositon = CFrame.new(241.999, 43,607, 318)
script.Parent.ClickDetector.MouseClick:Connect(function(player)
wait (5)
script.Parent.Parent.Model.PART1.CanCollide = true
	script.Parent.Parent.Model.Part.CanCollide = true
	print ("elevator going up")
	    if game.Workspace[player.Name]:FindFirstChild("Humanoid") then 
		playerWhoClicked.parent.HumanoidRootPart.CFrame = teleportpositon
	    end
end)

I would like to make an elevator but it won't work can you help?

1 comment

0

The PlayerWhoClicked is already set to the character. On line 08, remove the .Parent after PlayerWhoClicked

2 answers

✓ Accepted answer

Mistake 1: You passed the player through the function, but used a different variable to reference the player. On line 2, the variable is called "Player", but on line 8, you use "PlayerWhoClicked"

Mistake 2: You tried finding the HumanoidRootPart in the PlayerFolder on line 8. A ClickDetector passes the Player in the PlayerFolder. You tried finding the parent of said player.

local teleportpositon = 241.999, 43,607, 318

script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)

	wait (5)
	script.Parent.Parent.Model.PART1.CanCollide = true
	script.Parent.Parent.Model.Part.CanCollide = true
	print ("elevator going up")
	if playerWhoClicked.Character:FindFirstChild("Humanoid") then
		playerWhoClicked.Character:MoveTo(Vector3.new(teleportpositon))
	end
end)

1 comment

0

Can i use CFrame

I think nothings happening because of the weird CFrame at the top.

I think you accidentally put a , instead of a . when making the CFrame.

I think you could just change it to

CFrame.new(242, 43.5, 318)

and it would work.

2 comments

0

what line

0

The first one

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