So I'm trying to make an egg hatching system that involves a trade between a normal script and a local script. But I'm getting this error and I don't know why:
-- On normal script -- game.ReplicatedStorage.HatchEgg:InvokeClient(player, pet) -- On local script -- game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(player, pet) -- ...... -- end)
I dont know why LUA is treating OnClientEvent like an Instance. Thanks.
OnClientEvent
is only reserved for Remote Events. On Remote Functions You need to use OnClientInvoke
game.ReplicatedStorage.HatchEgg.OnClientInvoke = function(pet) return true --You should use remote functions to return stuff. end)
Also using the player
parameter OnClientInvoke is unnecessary. Just put the first parameter as pet
otherwise the 2nd parameter would be nil
.