So I have been coding fixes and fixes for my game but then I came across this issue. I didn’t attempt to debug it yet since I wasn’t unsure. Any ideas what this error means/how to fix it?
Pretty sure it has to do with firing RemoteEvents too often
What would be a counter to it since when the player joins all of them set off even though when no coins have been touched…
Some server script that you have is calling
ReplicatedStorage.Remotes.CoinEvent:FireClient(player, ...)
but you don’t have a LocalScript that defines the event itself.
ReplicatedStorage.Remotes.CoinEvent.OnClientEvent:Connect(function()
end)
What do you mean, can you explain it to me? I’m a bit confused.
you fire a remote event without a receiver. you’re shooting a gun into the sky
The only events I’ve found on the server are these ones.
new = function(position: Vector3, coinType: string, specificPlayer: Player?, specificId: string?)
local desiredCoin = coinsFolder:FindFirstChild(coinType)
if not desiredCoin then
error("Coin ".. tostring(coinType) .. " not found!")
end
local newCoin = {
CoinInstance = desiredCoin,
Position = position,
Id = if specificId then specificId else httpserv:GenerateGUID()
}
currentCoins[newCoin.Id] = {
Name = coinType,
Timer = desiredCoin.Timer.Value,
Amount = desiredCoin.Amount.Value,
Position = position
}
if specificPlayer then
coinEvent:FireClient(specificPlayer, "CreateCoin", newCoin)
else
coinEvent:FireAllClients("CreateCoin", newCoin)
end
end
and these client ones
coinRemote.OnClientEvent:Connect(function(action: string, data)
if action == "DestroyCoin" then
for i, v in tokensFolder:GetChildren() do
if v.Id.Value == data.Id then
v:Destroy()
return
end
end
elseif action == "CreateCoin" then
for i, v in tokensFolder:GetChildren() do
if v.Id.Value == data.Id then
return -- already exists
end
end
local coinInstance = data.CoinInstance:Clone()
coinInstance.Position = data.Position
coinInstance.InitialPos.Value = data.Position
coinInstance.Id.Value = data.Id
coinInstance.Parent = tokensFolder
if AnimateCoins == true then
coinInstance.SpinScript.Enabled = true
end
local conn
conn = coinInstance.Touched:Connect(function(hitPart: BasePart)
if plrs:GetPlayerFromCharacter(hitPart.Parent) ~= lp then return end
conn:Disconnect()
coinInstance:Destroy()
-- collect effect
makeCollectionParticles(data.Position)
playCollectSound()
coinRemote:FireServer(data.Id)
end)
end
end)
are coinevent and coin remote the same event
Let me check. I’m pretty sure they are the same event. There are no duplicates.
I also keep getting this random error from this code…
while task.wait(1) do
if not lp.Character or not lp.Character:FindFirstChild("HumanoidRootPart") then continue end
local playerPosition: Vector3 = lp.Character.HumanoidRootPart.Position
for i, v in tokensFolder:GetChildren() do
if not v:WaitForChild("InitialPos", 1) or not v:WaitForChild("Id", 1) then
warn("some descendants not found!")
continue
end
if (v.Position - playerPosition).Magnitude > 300 then
table.insert(unloadedCoins, {
Position = v.InitialPos.Value,
Type = v.Name,
Id = v.Id.Value
})
v:Destroy()
end
task.wait()
end
for i, v in unloadedCoins do
if (v.Position - playerPosition).Magnitude <= 300 then
local coinInstance = coinsFolder[v.Type]:Clone()
coinInstance.Position = v.Position
coinInstance.InitialPos.Value = v.Position
coinInstance.Id.Value = v.Id
coinInstance.Parent = tokensFolder
if AnimateCoins == true then
coinInstance.SpinScript.Enabled = true
end
local conn
conn = coinInstance.Touched:Connect(function(hitPart: BasePart)
if plrs:GetPlayerFromCharacter(hitPart.Parent) ~= lp then return end
conn:Disconnect()
coinInstance:Destroy()
-- collect effect
playCollectSound()
makeCollectionParticles(v.Position)
coinRemote:FireServer(v.Id)
end)
table.remove(unloadedCoins, i)
end
end
end
Remote events actually store these replies in a queue till there’s a receiver, which might be why it ‘exhausts’ after X amount of sends.
Would it be best to wait till the game loads?
You might have 3 child instances under the “tokenFolder” which are not coins. Should make sure to rule out any of these instances you’re not looking for before doing any other checks.
You could probably have it so the client notifies the server when it’s ready to receive these events, normally it won’t happen unless you’re firing the remote at a high rate or any functions / prep you have before the OnClientEvent takes a while to load.
It’s really up to you how you’d want to handle that part.
I’ll see what I can do and will let you know!
I fixed the issue by waiting for the game to load, it must be checking too early! Thank you for the help though!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.