Hello, Recently I have been having a problem with remote events. I am trying to help my friend by fixing his egg hatching system. While doing that I noticed that a vital RemoteEvent is not sending anything to the player (tested with print statements).
I have tried looking for naming errors already. There are no errors in output either.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Server Code:
local cost = 250
local PetModule = require(game.ServerScriptService:WaitForChild("PetModule"))
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= cost then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost
local pet = PetModule.chooseRandomPet()
print(pet.name.." selected")
local name = player.Name
game.ReplicatedStorage.HatchEgg:FireClient(player, pet) --Remote is not sending the anything for some reason
end
end)
Client Code: (Variables are above the shown function)
Perhaps the Client Code isn’t able to find the RemoteEvent, thus you should add a WaitForChild event that waits for the RemoteEvent to load into the ReplicatedStorage. I’m not a good scripter myself, but I would still want to give out all the help I can give. Try this adding this at the start of your ClientScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HatchEgg = ReplicatedStorage:WaitForChild("HatchEgg")
This is going to sound kinda obvious, but the remote event wouldn’t send unless you have enough cash to buy the pet. Can your perhaps provide your module so we can better help?
Are there any loops or waits above the OnClientEvent event? Because if that’s the case then just wrap the loop/wait in a coroutine and you should be good.