#why is the while loop continuing?
1 messages · Page 1 of 1 (latest)
bugs aside this has got to be some of the most unoptimized code, what are you trying to do?
the while loop ends when it shouldnt? or it doesnt end when it should
doesnt end when it should
because if the name doesn't equal redcan, equippedvlaue is never turned false, do else equippedvlaue=false if the name isn't redcan
also blud u cant add string to string
local speedamount = script.Parent
game.Workspace.DescendantAdded:Connect(function(descendent)
if descendent.Name == "redcan100speed" then
print("speed gained")
speedamount.Text = tostring(tonumber(speedamount.Text) + 100)
end
end)
The while equippedvlaue == true do loop starts as soon as DescendantAdded fires.
• Inside the loop, you wait 0.5s, then check the condition.
• Even if you set equippedvlaue = false later, that only happens after the if descendent.Name == "redcan100speed" condition is true.
• If the name isn’t "redcan100speed", that line never runs, so equippedvlaue stays true, and your loop never en
roblox has stupid proof string to number and number to string conversion in some cases
I gain the 100 speed and stuff but its like it skips over equippedvalue = false
basically everything works but that one part
so you keep getting 100 speed every 0.5s?
yeah
once the decendent is added
wait
am i slow?
i dont need a while loop there
right>
cuz like im just checking if the decendent added is redcan100 or not and the desendent added function checks for that
yea
also every object in the game that gets added skips over the name check and just runs infinitely
just make sure the object is named that before parenting it to the workspace
yuh it is 🙏 thx for the help
let me know if you need help with anything in the future