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

unable to break loop at certain point?

Asked by
3wdo 198
4 years ago

so in my last question the answer worked so i decided i wanted the loop to stop after the character reaches a certain size. so i added a break at the size of 5 but it keeps adding over 5. can someone help

game.ReplicatedStorage.titanshifted.OnServerEvent:Connect(function(player)
    local bds = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyDepthScale
local bhs = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyHeightScale
local bps = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyProportionScale
local bts = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyTypeScale
local bws = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyWidthScale
local hs = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").HeadScale
    print(player.name.." Titan Shifted")
    wait(3)
    while true do
           wait(0.1)
     bds.Value = bds.Value + 0.1
     bhs.Value = bhs.Value + 0.1
     bps.Value = bps.Value + 0.1
     bts.Value = bts.Value + 0.1
     bws.Value = bws.Value + 0.1
     hs.Value = hs.Value + 0.1
            if bds.Value == 5 and bhs.Value == 5 and bps.Value == 5 and bts.Value == 5 and bws.Value == 5 and hs.Value == 5 then
                break
        end
    end
end)


0
instead of using == try using <= and then set their values to 5 and make sure to add the break mixgingengerina10 223 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I think instead of doing a while true do statement, you could use a while size <= 5 statement, so it might look something like this

game.ReplicatedStorage.titanshifted.OnServerEvent:Connect(function(player)
    local bds = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyDepthScale
local bhs = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyHeightScale
local bps = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyProportionScale
local bts = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyTypeScale
local bws = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").BodyWidthScale
local hs = game.Workspace:FindFirstChild(player.name):WaitForChild("Humanoid").HeadScale
    print(player.name.." Titan Shifted")
    wait(3)
    while bds.Value <= 5 and bhs.Value <= 5 and bps.Value <= 5 and bts.Value <= 5 and bws.Value <= 5 and hs.Value <= 5 do
           wait(0.1)
     bds.Value = bds.Value + 0.1
     bhs.Value = bhs.Value + 0.1
     bps.Value = bps.Value + 0.1
     bts.Value = bts.Value + 0.1
     bws.Value = bws.Value + 0.1
     hs.Value = hs.Value + 0.1
    end
    bds.Value = 5
     bhs.Value = 5
     bps.Value = 5
     bts.Value = 5
     bws.Value = 5
     hs.Value = 5
end)
Ad

Answer this question