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

Clear my mind?

Asked by 3 years ago
Edited 3 years ago

Hello good morning,good night,good afternoon where ever you are.Hope your doing great, soooo the model character isn't teleporting to there checkpoint, before you leave, I honestly don't know what to do.In the script i created a global variable to always change its value to a new part each time the person reaches a new checkpoint.I did a simple check to see that the global variable is given value which would be the new checkpoint part and yes it is given the part and updates accordingly.My main problem though is changing my character position to the checkpoint's own.It sounded so self explanatory that I can just change the Character.HumanoidRootPart:MoveTo...() but that didn't work i also tried Character:MoveTo(...) still nothing and i also did player.Char........ and nothing happened. Sooo now i'm here.I don't expect you to give it to me straight forward but i just want to know where i went wrong and tips can help. :D

(The script is in Starter Character)

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

                    -- Change obby lvl
local part
local num = 0
player.Obbylvl.Changed:Connect(function()
    if num~= player.Obbylvl.Value then
        num = player.Obbylvl.Value 
    end
     part = game.Workspace["Level"..num]
    print(part.Name)
end)


            --Respawn--
local humanoid = char:WaitForChild("Humanoid")
while true do
    wait()
    if humanoid.Health == 0 then
        repeat wait() until humanoid.Health == 100
            wait(2)
        char.HumanoidRootPart.Position:MoveTo(part.Position)
    end
end

1 answer

Log in to vote
1
Answered by
iOwn_You 543 Moderation Voter
3 years ago
Edited 3 years ago

To teleport a character you should do

Character:SetPrimaryPartCFrame(checkpoint.CFrame + Vector3.new(0,5,0))

The reason you add to the y axis is so you spawn above the part and not inside of it.

0
ok i will try it mandibleknox 6 — 3y
Ad

Answer this question