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

CFrame Teleportation not working? Touched Part Event.

Asked by 4 years ago

I'm trying to create a simple teleportation. What I'm trying to do is make it like when you reach the end of the obby, you get points and then you teleport back to the brick. For some reason, it's not working and I don't know why. I'm attempting to teleport the HumanoidRootPart. (Also, the leaderstats value is not working but I'll post a separate question later.)

The descendants goes like this: game.Workspace.Folder.Part

01workspace.ObbyStuff.GetPoints.Touched:Connect(function(hit)
02    local brick = workspace.ObbyStuff.Teleporter
03    local debounce = false
04    if game.Players:GetPlayerFromCharacter(hit.Parent) then
05        if not debounce then
06            debounce = true
07            local plr = game.Players[hit.Parent.Name]
08            hit.Parent.HumanoidRootPart.CFrame = brick.CFrame
09            plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 100
10            wait()
11            debounce = false
12        end
13    end
14end)

I have no idea why it is not working, and I would like help to solve this issue. No errors at least from what I see. Any help is appreciated, because I am [Visible Confusion].

0
Sometimes I use print() to debug, such as seeing where the code gets to before stopping. QuantumPlasmic 84 — 4y
0
I ask the question I was confused about dovy iivSnooxy 248 — 4y
0
iivSnooxy What?????? Cynical_Innovation 595 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Try changing

1hit.Parent.HumanoidRootPart.CFrame = brick.CFrame

to

1hit.Parent.HumanoidRootPart.CFrame = brick.Position
2
why would u change cframe to a vector3?? Subsz 366 — 4y
Ad
Log in to vote
0
Answered by
exobyteXL 290 Moderation Voter
4 years ago

Try replacing hit.Parent.HumanoidRootPart.CFrame = brick.CFrame with

1hit.Parent:SetPrimaryPartCFrame(brick.CFrame)

Answer this question