Ad
Log in to vote
0

When a player first joins my obby, they're stuck halfway in the floor. How to fix?

Asked by 16 days ago

When you first join my obby, you're always stuck halfway in the floor until you reset or die which fixes it. Here is the script that causes the issue (It helps run the checkpoint system):

game.Players.PlayerAdded:Connect(function(plr)
    local stage = plr:WaitForChild("leaderstats").Stage
    plr.CharacterAdded:Connect(function(char)
        repeat wait() until plr.Character ~= nil
        wait(0.01)
        local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
        char:FindFirstChild("HumanoidRootPart").CFrame = checkpoint.CFrame
        char:FindFirstChild("HumanoidRootPart").Position = Vector3.new(checkpoint.Position.x, checkpoint.Position.y + 5, checkpoint.Position.z)
        wait(0.1)
    end)
end)
0
Can I have the link to your obby when you release it? fiddyfiddler 18 — 15d

3 answers

Log in to vote
0
Answered by 15 days ago
Edited 15 days ago
local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(player)
    local stage = player:WaitForChild("leaderstats"):WaitForChild('Stage')
    player.CharacterAdded:Connect(function(character)
        local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
        delay(.3, function() -- time game waits after you've spawned before you get teleported, can change to your .01 if you would like
            -- moves character 10 studs above the part (change the Y position, which is currently 10, to where you want them to be teleported to)
            character:SetPrimaryPartCFrame(checkpoint.CFrame + Vector3.new(0,10,0))
        end)
    end)
end)
0
Worked, Ty! BunjiBloxxer 12 — 15d
Ad
Log in to vote
0
Answered by 15 days ago
Edited 15 days ago
while Game.Players.PlayerAdded:wait().CharacterAdded:wait():move(Game["Run Service"].Stepped:wait()and Workspace.Stages[Game.Players:players()[#Game.Players:players()].leaderstats.Stage.Value].CFrame.p)==Game.Parent do end
0
No that doesn't work, also I don't think you're supposed to capitalize game. BunjiBloxxer 12 — 15d
Log in to vote
0
Answered by 15 days ago

I'm not sure this will work,

game.Players.PlayerAdded:Connect(function(plr)
        local stage = plr:WaitForChild("leaderstats").Stage
        plr.CharacterAdded:Connect(function(char)
            repeat wait() until plr.Character ~= nil
            wait(0.01)
            local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
            char:FindFirstChild("HumanoidRootPart").CFrame = 
            char:FindFirstChild("HumanoidRootPart").Position * CFrame.new(checkpoint.Position.X, math.rad(checkpoint.Position.Y * 5), checkpoint.Position.Z)
            wait(0.1)
        end)
    end)

Try that. I'm not thinking it will work, but it could.

Common errors that might come from this script:

If it doesn't work...

  • try removing * and put + near the checkpoint.Position.Y * 5

That's all I've got. Good luck!

0
It didn't work, thanks for trying to help though! BunjiBloxxer 12 — 15d
0
Thanks! fiddyfiddler 18 — 15d

Answer this question