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

Theres a string Value if that string value is "On" it would make a loop but the loop wont break?

RM.OnServerEvent:Connect(function(plr)

local ValueB = plr.Balloons

while true do

wait(1.2)

if plr.Bool.Value == "On" then

plr.leaderstats.Balloons.Value = plr.leaderstats.Balloons.Value + ValueB.Value

plr.PlayerGui.PartyClown.TextLabel.Text = ValueB.Value

plr.PlayerGui.PartyClown.TextLabel:TweenPosition(UDim2.new(0.655, 5,0.449, 0),"Out","Elastic",0.3,true)

wait(0.6)

plr.PlayerGui.PartyClown.TextLabel:TweenPosition(UDim2.new(0.5, 5,1, 0),"Out","Elastic",0.3,true)

else

break

end

end

end)

Im going to explain so theres a string Value the stringValue.Value is On when another script make it to "off" it wont break,im doing something wrong here,but i cant know what!

1 comment

0

Remove the break after the else and make the else line "else then return end". Then do one end then the break.

1 answer

While loops tend to run and run and run on their lines ignoring the RE event from the top, therefore you must put another event inside to change the value, that way, the while loop will not skip that event.

Ie:

local stop = false
part.Touched:connect(function()
 while true do
  part.Touched:connect(function()
   stop = true
  end
  if stop then
   break
  end
  wait(1)
  print'Owo'
 end
end)
`

1 comment

0

Note this is a sample event, recomended anchoring the part

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