So when I open an egg, it spams the egg. If I spam the e button, the cooldown is not working. I don’t know why it was working fine yesterday, but I don’t know why it’s not working.
It only spam in studio but no in game I don’t know why.
I hope you can help me.
Axominock
(Axominock)
February 24, 2023, 4:47am
2
Here, when you are adding a new cooldown, you are trying to index EggCooldowns. The problem is, is that #EggCooldowns is lower than #EggCooldowns + 1.
Instead, when you add a new cooldown table, it should look like this:
Players.PlayerAdded:Connect(function(Player)
table.insert(EggCooldowns, {Player.Name, false})
end)
Is that all I have to change on my script?
Axominock
(Axominock)
February 24, 2023, 5:02am
4
I think so. Does the cooldown work if you make the change?
The thing is it only spam on studio but in game its not it’s so weird.
Axominock
(Axominock)
February 24, 2023, 5:08am
6
Did you check if Players.PlayerAdded:Connect() is firing?
It still spam the egg when I change the code.
I added an print statement below the playerAdded but its not printing when I play the game on studio so weird.
Players.PlayerAdded:Connect(function(Player)
print("PlayerAdded")
table.insert(EggCooldowns, {Player.Name, false})
end)
Axominock
(Axominock)
February 24, 2023, 5:13am
10
Did you check if function EggHandler:Int() is being called? Maybe the Players.PlayerAdded isn’t firing becuase the function hasn’t been called yet.
It wouldn’t open an egg if its not called, though?
it does print called
function EggHandler:Int()
print("Called")
Players.PlayerAdded:Connect(function(Player)
table.insert(EggCooldowns, {Player.Name, false})
end)
Players.PlayerRemoving:Connect(function(Player)
for i,v in pairs(EggCooldowns) do
if v[1] == Player.Name then
v = nil
end
end
end)
Events.OpenEgg.OnServerInvoke = OpenEgg
end
Axominock
(Axominock)
February 24, 2023, 5:26am
13
Is function EggHandler:Int() being called before anything like wait() or task.wait()?
-- [[ Services ]]
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
-- [[ Variables ]]
local GameAssets = ReplicatedStorage.GameAssets
local Events = GameAssets.Events
local ServerModules = ServerStorage.ServerModules
-- [[ Modules ]]
local EggHandler = require(ServerModules.EggHandler)
local CodeHandler = require(ServerModules.CodeHandler)
local DataHandler = require(ServerModules.DataHandler)
local GameHandler = require(ServerModules.GameHandler)
local GlobalLeaderboardHandler = require(ServerModules.GlobalLeaderboard)
local PetHandler = require(ServerModules.PetHandler)
local PortalHandler = require(ServerModules.PortalHandler)
local ProductHandler = require(ServerModules.ProductHandler)
-- [[ Initialize ]]
EggHandler:Int()
CodeHandler:Int()
DataHandler:Int()
GameHandler:Init()
GlobalLeaderboardHandler:Int()
PetHandler:Int()
PortalHandler:Int()
ProductHandler:Int()
Events.OpenEgg.OnServerInvoke = function(Player, EggName, Action)
return EggHandler.OpenEgg(Player, EggName, Action)
end
system
(system)
Closed
March 10, 2023, 5:26am
15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.