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 3 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

workspace.ObbyStuff.GetPoints.Touched:Connect(function(hit)
    local brick = workspace.ObbyStuff.Teleporter
    local debounce = false
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        if not debounce then
            debounce = true
            local plr = game.Players[hit.Parent.Name]
            hit.Parent.HumanoidRootPart.CFrame = brick.CFrame
            plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 100
            wait()
            debounce = false
        end
    end
end)

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 — 3y
0
I ask the question I was confused about dovy iivSnooxy 248 — 3y
0
iivSnooxy What?????? Cynical_Innovation 595 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Try changing

hit.Parent.HumanoidRootPart.CFrame = brick.CFrame

to

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

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

hit.Parent:SetPrimaryPartCFrame(brick.CFrame)

Answer this question