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)
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!)