Hello everyone , im trying to make worker system for eachplayer. Everything is cool but i need suggestions
game.ReplicatedStorage.Events.WorkingStatue.OnServerEvent:Connect(function(player,WorkingStatue,WorkerInfo)
while true do
if WorkingStatue == true then
wait(1)
workerHumanoid:MoveTo(game.workspace.Checkpoints.Dest.Position)
idleAnimationTrack:Stop()
runAnimationTrack:Play()
workerHumanoid.MoveToFinished:Wait()
runAnimationTrack:Stop()
while WorkerInfo[“Count”] < WorkerInfo[“Sieveable”] do
local ore = GetRandomOre()
sieveAnimTrack:Play()
WorkerInfo["Count"] = (WorkerInfo["Count"] + 1)
wait(2)
print(ore)
sieveAnimTrack:Stop()
end
wait(1)
runAnimationTrack:Play()
workerHumanoid:MoveTo(game.workspace.Checkpoints.Dest2.Position)
workerHumanoid.MoveToFinished:Wait()
runAnimationTrack:Stop()
WorkerInfo["Count"] = 0
else
wait(1)
runAnimationTrack:Play()
workerHumanoid:MoveTo(game.workspace.Checkpoints.Dest2.Position)
workerHumanoid.MoveToFinished:Wait()
runAnimationTrack:Stop()
sieveAnimTrack:Stop()
idleAnimationTrack:Play()
end
end
end)
this script is a worker stopper script
when you clicked gui worker needs to stop no matter what
firstable you need to click the gui for set WorkerStatue = false. when you clicked it it gets the info from client and send it to the server but when WorkerStatue = true and you set it false ,script dont break the WorkerStatue = true loop and it bugs. i need a way to break the loop
im new at forum sorry if something is wrong
thanks