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

Brick that awards player points and then teleports you to another brick?

Hi, I was wondering how to make a brick that gives a player PP's and then instantly teleports you to a different brick. I have thiss code here but idk how to do the teleport part

local pointgiver = script.Parent 
pointgiver.Touched:connect(function(pointgiver)
local g = game.Players:GetPlayerFromCharacter(pointgiver.Parent)
if pointgiver:IsA("Part") and (g) then 
pps = game:GetService("PointsService")
if pps:GetAwardablePoints() >= 1 then
    pps:AwardPoints(g.userId, 1) 
end
end
end)

2 answers

There's two different ways you can teleport someone.

First, you can change the CFrame of the character's torso.

Workspace.Player.Torso.CFrame = CFrame.new(x#, y#, z#)

The second way is to use the MoveTo method on the character model itself.

Workspace.Player:MoveTo(Vector3.new(x#, y#, z#))

Hope I helped! You can also read the wiki's article on teleportation.

ps = game:service'PointsService'
sp = script.Parent
PartToTeleport = workspace.Part --Change workspace.Part to the part you want the player to teleport to!

sp.Touched:connect(function(h)
	local p = game.Players:GetPlayerFromCharacter(h.Parent)
	if p ~= nil then
		p.Character:MoveTo(PartToTeleport.Position)
		pcall(function()
			ps:AwardPoints(p.userId, 1)
		end)
	end
end)

Try that. (Don't forget to change PartToTeleport to the part they need to teleport to!)

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