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

How do i fix this teleport script from not working?

Hi, i made a script that's located in ServerScriptService. When a player says /jail username, it is meant to teleport them to a certain place on the map, however it isn't working.

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		for i,player2 in pairs(game.Players:GetPlayers()) do
			if msg == "/jail "..player2.Name then
				player2.character.Torso.CFrame.new(34.5, 0.5, -66.7)
			end
		end
	end)
end)

Any help is hugely appreciated, thanks.

3 comments

0

Try capitalizing the c in Character, that's what causes most problems in scripting.

0

Mendoza is right. However I recommend putting the .Chatted function in StarterPlayerScripts and use RemoteEvent to fire in the server.

0

And also try to split the message by using string.match()

1 answer

You are not setting the CFrame of the torso properly. I recommend changing line 5 to:

player2.Character.HumanoidRootPart.CFrame=CFrame.new(34.5, 0.5, -66.7)

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