Code GUI scripting

Hello, I need help with code ui scripting
I coudn’t find the script that we put the name for code I mean I could find the the place to put the name of the code for code script.

So the first picture is located inside Code UI called Manager and the second picture is located in serverstorage called PlayerData.

I put the code in the second picture but it didn’t work it keep on saying code not found.

Here is a pictures


3 Likes

Use WaitForChild() to make sure there is no errors with waiting.

1 Like

Can you show the part of code with the error?

1 Like

Where on the first picture or second picture and which number
I am so sorry I am not a scripter.

1 Like

line 2 to 3, everything else should be loaded in.

1 Like

There is no error the only thing i couldn’t find is where do i need to put the code name.

1 Like

Can you show the code the receives the remote function?

1 Like


image

This is the code that is inside ui

1 Like

I mean the script that uses .OnServerInvoke for the UseCode remote function.

1 Like

That is what I am finding for…
There are the only i could find
I tried to write it do here but It didn’t work

here is a second picture i find
image

1 Like

You mean you are invoking the code remotefunction but are never receiving the function anywhere?

1 Like

Yes, I couldn’t find the script to put the code name for example I put the code as a “NewGame” This is the code name I coudn’t find to put.

1 Like

Since you aren’t receiving the remote function, that is the reason res == nil.

You have to create a script that receives the remote function and check from the PlayerData if the code is valid, if it is not return nil or if the already used the code return false

1 Like

Do you have a script so I can use it and where do i put?
Right now i just create a RemoteEvent called codeEvent

1 Like

I don’t have a script to use, but I can give you an example on how to make one:
Create a script in serverscriptservice and call it codeCallback
Make a function in your player data script that gets the value of codes
In the codeCallback script receive the remote function that you gui script sends
Check from the PlayerData if the code is valid, if it is not return nil, if the already used the code return false, or if the code is valid return true

Remember that UseCode has to be a remote function not a remote event

This would be the basic gist of how to make what you desire

Ok, I will send you the screenshots after i ma done with it.

I am confuse at 4 so i need to make a script in codeCallback that receive the remote function then my ui script sends?

Yeah, you have to use .OnServerInvoke

This is the script so far i got and i have a another one too ignore the box

local function yourRemoteFunction(data)

local result = data * 2
return result

end

local remoteFunction = script.Parent.InvokeFunctionRemote

remoteFunction.OnServerInvoke = function(player, data)
return yourRemoteFunction(data)
end

What is data and why are you multiplying it by 2?

Also, the remotefunction you defined is wrong, it is replicatedstorage.Function.UseCode
You have to create a function in your playerData script to get codes, also playerData script has to be a module. If it isn’t a module you will transfer all code in codeCallback script to playerData script.