my goal is that when value = false then the loop breaks and when the value = true it begins
What doesn’t work about it? You should also probably do while loop.Value do instead of while true do. Additionally, you created a loop variable and don’t use it in the if statement lol.
probably exhaustion
while true do
print("hi")
wait() -- Don't forget to yield
end
it, just simply doesn’t work, i forgot to mention im a beginner- and sorry for the late response i did not expect anyone to reply this early- the script is a server script
Try this, but do note that you have to change the value for it to work.
local FireGun = script.Parent:WaitForChild("FireGun")
local loop = script.Parent:WaitForChild("loop")
FireGun.OnServerEvent:Connect(function(player)
while loop.Value do
print("hi")
end
end)
hm, that doesnt seem to work either, im pretty sure its because of this script too
ive attached this video, just in case there are outside elements affecting it
The value isn’t being changed on the server. When you change something via explorer in a play test (or in a localscript), you’re only changing it locally. Consider using a server script to change the value to true and then try again.
ohh i did not know thats how it worked- thank you
There isn’t enough whitespace, and this may create race conditions during compiling. Add more spaces between lines to fix!
there are so many things wrong with this code.
- you should not be doing while loops without
task.wait()
unless your intentions are to crash the server - secondly you should just do
while script.Parent.loop.Value == true do task.wait()
. the wait function is there to not crash the server
i did do those stuff, i just created a new script with only the things i need as my code doesnt get stolen
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.