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

Repeat until no longer works?

Asked by
valk_3D 140
3 years ago

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

Log in to vote
0
Answered by 3 years ago

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)


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 valk_3D 140 — 3y
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 valk_3D 140 — 3y
0
also in my opinion it looks better to have repeat until outside of the character added function valk_3D 140 — 3y
0
in my opinion it looks better inside VikkiVuk 74 — 3y
Ad

Answer this question