I need some help with remote functions as I’m dumb and yeah…
So I have a remote function and it just doesn’t work.
Local script
script.Parent.MouseButton1Click:Connect(function()
local chosenPet = EggOpener:InvokeServer(value)
print(chosenPet)
end)
Server Script
EggOpener.OnServerInvoke = function(player, value)
local EggSelected = petRoll.Roll(value)
local chosenPet = petModule.chooseRandomPet(EggSelected)
return chosenPet
end
(It’s supposed to print out the pet, but it doesn’t print anything, the Module scripts work indeed)
We would probably need to see more of the script to see what’s going wrong, but step 1 is to check output for any errors, and then make sure your modules aren’t breaking or doing something wrong.
Also keep in mind if something is stopping the .OnServerInvoke from running such as a while true do loop.
The module scripts work completely fine, the 1st one is to determine if it’s using like a first egg or 2nd egg, and the 2nd module is to determine the pet from that specific egg, it works tho but it doesn’t print out the chosenPet (even if i do chosenPet.Name)
So the value determines which egg he’s gonna open, example if i stand on the first egg, the value is one, and in the module script if it’s 1 then it will get a random pet from the Egg number 1
script.Parent.MouseButton1Click:Connect(function()
print("The Button Click Works")
local chosenPet = EggOpener:InvokeServer(value)
end
EggOpener.OnServerInvoke = function(player, value)
print("The Invoke works!")
local EggSelected = petRoll.Roll(value)
print("The Egg has been selected!")
local chosenPet = petModule.chooseRandomPet(EggSelected)
print("The pet has been chosen!")
Ok, there is something wrong with the remote function on the server script. Try to replace that EggOpener.OnServerInvoke
with the place of the remote function.