I am trying to use the value of a BoolValue in a tool in the client in a wait loop (for testing only) where the loop is waiting for the value to change which was requested via an InvokeServer.
ClientCode is
SetBotValue:InvokeServer(Bot,"DigEnded",true)
while (Bot.DigEnded.Value == false) do
wait()
print("BotDig waiting tag change=",Bot.DigEnded.Value,".")
end
print("BotDig ",Bot.Name," Ended")
server code is
local function OnSetBotValue(player,Bot,ValueName,Value)
print("SetBotValue ",player.Name,Bot.Name,ValueName,Value)
local target = Bot:FindFirstChild(ValueName)
if target then
target.Value = Value
else
print("SetBotValue target ",ValueName," notfound")
end
end
I think why the server is always printing false is because you didn’t put a print command after the line(target.Value = Value), which I would predict would also print true.
the print command(print("BotDig waiting tag change=",Bot.DigEnded.Value,".")) in the client code would always print false because once DigEnded is true it wouldn’t print anymore.
on the server t.The if target.e is confirming that the request value item has been found from the FindFirstChild statement.
on the client the print does not stop as the loop never exits.
this is indicated by the (hard to see) print showing 3724 repeats.
the screen shots show the property whilst the loop is running.
What I don’t get is why they are different since the server has set the value to true as required by the InvokeServer and seen in the server screen shot.
local Bot = script.Parent.Bot
while Bot.DigEnded.Value == false do
wait()
print("BotDig waiting tag change=",Bot.DigEnded.Value,".")
end
print("BotDig ",Bot.Name," Ended")
That does add some light onto the fact that this works ok the first time but not subsequently.
It implies that I have somehow lost the connection to some part of the game.
I added
print(“Bot FullName”,Bot:GetFullName())
to both client and server
and got
Bot FullName Workspace.Player1.Controller.Handle.BotMaster
from both client and server.
Still failing on second dig so will have to check all things each time to see if I can see a difference.
This may take some time.
Thanks for your help so far.
Ok. Found it. Before calling the digging routine I set the DigEnded value to false.
The problem was I was doing it on the client in two locations I had missed.
The first time worked because the server value was already false.
Any subsequent time the server value would not be changed so the code just went wrong.
Fixed by searching again for all instances where the DigEnded.Value in the client was being set and replacing that with the ServerInvoke.
I will mark your response as the solution as it was that which gave me the change to my research thinking which concluded with this fix.