Hello everyone, so I recently encountered this error in scripts. My loop/repeat loop or while true loop cant fire a remote event and I can’t figure out why?
Here is the script:
local minutesVal = game.ReplicatedStorage.TimerVal.minutesVal
local secondsVal = game.ReplicatedStorage.TimerVal.secondsVal
local bought = game.ReplicatedStorage.ShopEvents.LocalButtons.invisibilityButton
repeat
wait()
if minutesVal.Value == 0 and secondsVal.Value == 0 then
print("GOT YA")
bought.Value = false
game.ReplicatedStorage.ShopEvents.ClaimedFolder.Claimed:FireServer()
end
until bought.Value == true
Is this error due to the lack of wait time? or something else?
I would create a variable that waits for the event and then just refer to that variable has the event. If I didn’t explain myself correctly, take this as an example:
local ShopEvents = game.ReplicatedStorage:WaitForChild("ShopEvents", 100)
local Remote = ShopEvents.ClaimedFolder:WaitForChild("Claimed", 100)
Remote:FireServer()
Try doing it so you only have to fire it once.
Anyways, I’ll have to go now. I might come back in a few hours and see if your problem has been solved, if it isn’t then I’ll try to help you.
A while ago I made a script that fired a RemoteEvent every RunService.Heartbeat, which fires faster than while wait() do, so I don’t really think it would be a problem.
if the bought value is set to true by default, and the minute or the secondval is not 0 then it will never fire that event, as it will just exit the loop.
game.ReplicatedStorage.ShopEvents.ClaimedFolder.Claimed.OnServerEvent:Connect(function()
print("hello! it works.")
end)
this is the code i used to check it serversided and it worked with secondval and minuteval at 0, and bought at false.