#weird errors
1 messages · Page 1 of 1 (latest)
RemoteFunction does not use OnClientEvent or FireClient
Next time, look at the docs if it starts telling you it's not a valid member
https://create.roblox.com/docs/reference/engine/classes/RemoteFunction
what should i use
fixed quality
Well do you need a response? Or just to tell something that something happened
huh
** You are now Level 5! **
Okay. Why did you even use RemoteFunction in the first place.
because?
that’s simple
and easy
What do you mean "because"? Surely you had a reason for using it. What was the intention behind it? Why was it added?
Okay... and how does that work? Are you using it so the client can request to change character?
it’s not completely done but i have a script rn so it sets your character to the test character set up and when you join you will see the attack buttons
but for some reason those errors appeared and now i don’t see the buttons
It doesn't matter. I'm asking so I know what you need to use, RemoteEvent or RemoteFunction, since you asked
remote function
I think we're not quite on the same page.
You asked me "so what should I use" so I assumed you were asking me if you should use RemoteFunction or RemoteEvent.
Are you asking what event & function you should use for RemoteFunctions?
i meant instead of firing what should i do for the code
Well if you read the doc I linked you'd see what functions you'd need to use.
i did
multiple times
If that was too technical, read this instead:
https://create.roblox.com/docs/scripting/events/remote#remote-callbacks
this fixed it but added another error
that's a variable, not a function, so its more like
.OnServerInvoke = function, which the example code in the docs I linked did do as well
i did the server one
isn’t this exactly what i did
ok that one is fixed
How many more errors are there?
these 2
The first one you forgot an end for your event connection
fixed
what about the last one
and my entire punch system just broke randomly
this is so annoying
This is programming. Sometimes you introduce more issues than you solve.
Just send a screenshot of the error and where it is. having to watch a video to find it is obnoxious
We just talked about that. That's why I was linking things.
yea but i’m using connect function so what would i replace it with
Read. What. I. Linked. It. Is. All. There.
would i do the same thing
from the thing I linked.
so is connect(function(CharacterData) client or server
There is no Connect.
When you Invoke, it'll return whatever the server returned in OnServerInvoke
Because you're trying to use a RemoteFunction. RemoteFunctions do not have OnClient event. I thought that was made ridiculously clear.
Maybe you do want to use a RemoteEvent, but accidentally used RemoteFunction.
was made clear where?
Events.EquipCharacterClient.OnServerInvoke = function(Player, CharacterData)
would this work
Yes, if that bit of code is on the server.
i will have to try
was said 1 time that it doesn’t use client
But twice you were pointed to what it showed you to use. If you had read those you would have seen the proper way to use a RemoteFunction.
i did use it
the correct way
then i asked a simple question because i was a little confused
but you couldn’t take the 10 seconds to think about what i had said
You were trying to use RemoteEvent stuff on a RemoteFunction
So I said that and linked you two docs that contained the correct functions to help you see the things you should be using.
I was hoping that was enough, as you'd read them, see some example code, and be like "oh, that's how RemoteFunctions work, cool" and all would be solved.
But as you responded saying it was still an error, I was confused and thought you did not read anything I was saying
I realized a little bit through that maybe we were having some communication issues
but it just continued to seem that you weren't paying attention to what I was saying.
If the docs were confusing, you could have said "hey these are still confusing. Can you explain?"
But saying "which one do I use", it made it seem like you didn't read it, because the answers were in both of those linked docs.
So I became frustrated because I felt like I was repeating myself and you appeared to ignore it without acknowledging what I gave you
Does that make sense?
i explained to you many times i meant which one do i use the client code or the server code
to which you replied “look what i linked”
Yes, because both sides are different
RemoteEvents and RemoteFunctions do not use the same things at all
So I wanted you to look into what I linked because it gave examples on what was needed to make RemoteFunctions work
which i was just simply asking for 1 answer because i was a little confused which you could’ve just simply given and said “yes use the server one” or “yes use the client one” but because we’ve been going back and forth i still have no idea what i should do so my game is still currently broken
"which one do I use" didn't make sense in context, so I was confused. That's where that came from.
We can try and fix it again with a clean slate, if you'd like. One step at a time, with any errors that come up.
i just need to fix OnClientEvent is not a valid member of RemoteFunction "ReplicatedStorage.Events.EquipCharacterClient"
any hopefully it works
Cool, so OnClientEvent is for the server, so it knows when the Client has sent an event.
The RemoteFunction equivalent, but used differently, is OnServerInvoke, which as you did before, set to a function that is called when the client does InvokeServer.
Does that make sense?
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
You did it right before
OnServerInvoke is a variable, so you have to set that to whatever function you want ran
(What you showed me):
#1359245599207325817 message
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
** You are now Level 6! **
Okay but that isn't right
I see what you're saying, but it's saying you can set it, just not get it
So you can set it to the function you want called
i’m a little confused
That's okay!
So OnServerInvoke isn't an event or anything. It's not a function you call or event you connect to.
It looks like one, yeah, but it's just a variable that the RemoteFunction will read to know what to call
So all you're doing is saying "here's the function I want you to run when you are invoked by the client"
So do OnServerInvoke = function and the rest of your function
so for example
remoteFunction.OnServerInvoke = function()
print("The function was used!")
end
does the function have to have player in it
well that’s fixed now
and there’s a new error
isn’t this wonderful
fixed both of those
and there’s another one
for the love of
OnServerInvoke can only be implemented on the server
Oh yes, it does, good call!
Yeah, this can only be on the server
How does the equip work? Does the client ask the server to equip a character?
the client is the player right?
The client is the player's computer essentially, yeah
The server is Roblox
then yes i’m pretty sure
when the player joins they are automatically put onto the first class/ the base class
in the characters menu they can choose a new character
i can show you everything i have so far
So the server would have OnServerInvoke in a script in ServerScriptService.
When that's invoked by the client using InvokeServer, they'd supply the name of the character they want to change into (or whatever you wanna do)
In the server's invoke function, you'd then swap out the player's character for the new one
So two scripts:
- Server: OnServerInvoke, which contains the function that changes player character
- Client: InvokeServer with the character to change into
i’m still very confused because my punch was working and i don’t think this line of code has anything to do with it and i don’t know which one to use
Server script
local remoteFunction = game.ReplicatedStorage.RemoteFunction
remoteFunction.OnServerInvoke = function(player, param1, param2)
print("Player invoked me!", param1, param2)
return 10
end
Client script
local remoteFunction = game.ReplicatedStorage.RemoteFunction
local resultFromServer = remoteFunction:InvokeServer("first parameter", "second parameter")
print("The server responded!", resultFromServer)
Well we gotta make sure we fix what we know we can, and deal with new errors that pop up. One step at a time!
how do i add this
Well you wouldn't add exactly that, but you'd use that as a guide to how you need to use your own RemoteFunction
i don’t get it
Okay, how about you show me what you have so far
I mean the issue is you're still not doing the RemoteFunction right
I have really really tried to explain it to you, giving you examples and docs, but it's just not clicking for you
There's nothing else I can really do here. Maybe someone else can come in and give it a try, maybe they'll explain it in a way that makes more sense for you
idk what to put
I think that means that you're not familiar enough with programming and lua yet and need to practice more on more basic things. Making a combat system really isn't the best first thing to do
your explaining it in ways i dont understand
again i dont know wether its server side or client side
But I tried to explain that here: #1359245599207325817 message
You Invoke on the client, and OnServerInvoke on the server
InvokeServer goes in a LocalScript, OnServerInvoke goes in a regular Script
Character gets changed on the server, client asks the server to change them
ok now i get it
i need to use invokeserver
@honest pine InvokeServer is not a valid member of RemoteFunction "ReplicatedStorage.Events.EquipCharacterClient"
i just dont get it
why is roblox coding so bad
It's not bad, you just need more practice.
Is this you trying to invoke on the client?
yea
the script im on rn is a local script
Okay, so to InvokeServer, you'd just do EquipCharacterClient:InvokeServer(player, characterName)
do i need to do the events because that’s the folder it’s in
the character client
It's not literal. I'm just trying to show you how you'd do it
FINALLY
I FIXED THAT ONE
HOLY
Workspace.GraysenP426.CharacterAttacks.SpecialAttacksInputHandle:48: Expected <eof>, got 'end'
what is eof
the line of code its directing me to is just an "end"
Basically means you mistyped something.
Show me that script
This is the wrong way to do InvokeServer, plus the code is outside the event rather than inside it
what should i be doing?
Is this the server part?
this is the local script
Didn't we just do the InvokeServer part and you said you fixed it?
no it’s not that
the error is gone for that one
it’s this
okay just get rid of that end, it doesn't belong there
oh ok understood
ohhh i know why i had that
because i had a function there
all errors are gone!
but now my punch animation is broken
sigh
all this hard work
i think i’m just done with this game
@honest pine is it possible to revert back to an old save
Possibly but Google may be better at answering that