Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

Ad
Log in to vote
0
Answered by 10 years ago
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!)

Answer this question