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:
1 | -- On normal script -- |
2 |
3 | game.ReplicatedStorage.HatchEgg:InvokeClient(player, pet) |
4 |
5 | -- On local script -- |
6 |
7 | game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect( function (player, pet) |
8 | -- ...... -- |
9 | 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
1 | game.ReplicatedStorage.HatchEgg.OnClientInvoke = function (pet) |
2 | return true --You should use remote functions to return stuff. |
3 | end ) |
Also using the player
parameter OnClientInvoke is unnecessary. Just put the first parameter as pet
otherwise the 2nd parameter would be nil
.