Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Can I have the link to your obby when you release it?

3 answers

✓ Accepted answer
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)

1 comment

0

Worked, Ty!

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

1 comment

0

No that doesn't work, also I don't think you're supposed to capitalize game.

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!

2 comments

0

It didn't work, thanks for trying to help though!

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.