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

Repeat until no longer works?

This is part of a local script

--#Basic player variables
local Character
local Human
local HumanRoot

--#Original values of stuff
local OGravity
local OWalkSpeed
local OJumpPower

local _Delay = false 

--#Assigning variables
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	Character = char
	Human = char:WaitForChild("Humanoid")
	HumanRoot = char:WaitForChild("HumanoidRootPart")
	
	OWalkSpeed = Human.WalkSpeed
	OJumpPower = Human.JumpPower
	OGravity = workspace.Gravity
end)

--#Make sure the player exists
repeat wait() until Character ~= nil and HumanRoot ~= nil and Human ~= nil

the script does not make it past the repeat until line nor does it output an error. The last time i ran this script(4/9/21) it did work but now it no longer does.

1 answer

I really dont understand why did you just do that, since i dont recommend doing it that way, you can just use the repeat wait() until char in the characteradded function, it would simplify a lot of code, and you really dont need to wait for the humanoid and humanoidrootpart if the character is loaded then so is the hum, and humrootpart. I dont think this will fix your code, but this is how its done better.

--#Original values of stuff
local OGravity
local OWalkSpeed
local OJumpPower

local _Delay = false 

--#Assigning variables
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
    OWalkSpeed = Human.WalkSpeed
    OJumpPower = Human.JumpPower
    OGravity = workspace.Gravity

    repeat wait() until char

    print("Congrats! The player exists")
end)


4 comments

0

i used repeat until because when i tried to use the variables they would return as nil otherwise i wouldnt have used repeat until

0

and the only reason i cheked all of the variables is to make sure they are assigned to since the variables will be used immediately after

0

also in my opinion it looks better to have repeat until outside of the character added function

0

in my opinion it looks better inside

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