im making a fnaf bot script where it checks what room the bot is in, gets a random number to check which room to go to next. and when it moves it changes the room name, it puts the old bot pose into a folder in replicatedStorage and puts the new one into a folder in workspace, theres also a random number generator so that checks if its lower or equals the bot level and if it is, moves, if it doesnt, it repeats.
for some reason it stops working after a while, i think it has something to do with the if statements, can anyone help?
local poses = game.ReplicatedStorage.CalebPoses local currentPose = workspace.Poses local currentRoom = script.Parent.Value local roomOption = nil local botLevel = 20 local moveChances = nil local doorCheck = workspace.RightDoor["RightDoorStatus"] local attackOption = nil currentRoom = "Start" wait(math.random(5,10)) while task.wait(math.random(5,10)) do moveChances = math.random(1,20) if moveChances <= botLevel then if currentRoom == "Start" then roomOption = math.random(1,2) if roomOption == 1 then moveChances = nil currentRoom = "Main Party Room" poses.CalebMainPartyRoom.Parent = currentPose currentPose.CalebIdle.Parent = poses end if roomOption == 2 then moveChances = nil currentRoom = "Parts And Service Door" poses.CalebNearPartsAndServiceDoor.Parent = currentPose currentPose.CalebIdle.Parent = poses end end moveChances = math.random(1,20) if moveChances <= botLevel then if currentRoom == "Main Party Room" then roomOption = math.random(1,5) if roomOption == 1 or 2 or 3 then moveChances = nil currentRoom = "Main Party Room Stare" poses.CalebMainPartyRoomStare.Parent = currentPose currentPose.CalebMainPartyRoom.Parent = poses end if roomOption == 4 then moveChances = nil currentRoom = "Parts And Service Door" poses.CalebNearPartsAndServiceDoor.Parent = currentPose currentPose.CalebMainPartyRoom.Parent = poses end if roomOption == 5 then moveChances = nil currentRoom = "Party Room Hall" poses.CalebPartyRoomHall.Parent = currentPose currentPose.CalebMainPartyRoom.Parent = poses end end moveChances = math.random(1,20) if moveChances <= botLevel then if currentRoom == "Parts And Service Door" then roomOption = math.random(1,3) if roomOption == 1 or 2 then moveChances = nil currentRoom = "Main Party Room" poses.CalebMainPartyRoom.Parent = currentPose currentPose.CalebNearPartsAndServiceDoor.Parent = poses end if roomOption == 3 then moveChances = nil currentRoom = "Parts And Service" poses.CalebPartsAndService.Parent = currentPose currentPose.CalebNearPartsAndServiceDoor.Parent = poses end end moveChances = math.random(1,20) if moveChances <= botLevel then if currentRoom == "Main Party Room Stare" then roomOption = math.random(1,5) if roomOption == 1 or 2 or 3 or 4 then moveChances = nil currentRoom = "Hallway" poses.CalebHallway.Parent = currentPose currentPose.CalebMainPartyRoomStare.Parent = poses end if roomOption == 5 then moveChances = nil currentRoom = "Main Party Room" poses.CalebMainPartyRoom.Parent = currentPose currentPose.CalebMainPartyRoomStare.Parent = poses end end moveChances = math.random(1,20) if moveChances <= botLevel then if currentRoom == "Hallway" then roomOption = 1 if roomOption == 1 then moveChances = nil currentRoom = "Door" poses.CalebDoor.Parent = currentPose currentPose.CalebHallway.Parent = poses end end if currentRoom == "Door" then wait(7,10) if doorCheck == 1 or true then moveChances = nil currentRoom = "Main Party Room" poses.CalebMainPartyRoom.Parent = currentPose currentPose.CalebDoor.Parent = poses else local player = game.Players:GetPlayerFromCharacter() player:Kick() end end end end end end end end