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

unable to break loop at certain point?

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)


1 comment

0

instead of using == try using <= and then set their values to 5 and make sure to add the break

1 answer

✓ Accepted answer

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)

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