Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Error: OnClientEvent is not an valid member of Remote Function "game.ReplicateStorage.HatchEgg"?

Asked by 3 years ago

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.

0
I suggest using something other than InvokeClient, since it can hang forever if it throws an error. CrypxticDoge 135 — 3y

1 answer

Log in to vote
2
Answered by 3 years ago

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.

0
Note: A reason why LUA treats an event like an Instance is because it ALWAYS assumes that you want an instance. There is a hierarchy when you use the dots. So Lua assumes that a (e.g. part) is named OnClientEvent, so it'll search for that. Dovydas1118 1495 — 3y
0
Roblox Lua to be specific DiamondComplex 285 — 3y
0
Thanks! bruno13bruno13 78 — 3y
Ad

Answer this question