Remote Event Variable Help

I believe that, instead of doing

...Mouseclick:Connect(function()
     pop(game.Workspace.DS.D1) --pop being a function

you could try and straight up go with the function in the connect area, without building a function for that specific click

...Mouseclick:Connect(pop) --the pop function has the parameters as the mouseclick event

the parameters that you declared when you MADE the function will be the same in the function itself. What do I mean, well, the parameters that you use when you make the function will be nil in the moment you make the function, but when you declare them in an object (which involves a remoteevent and “connect” on it), those nil parameters turn into the remoteevent, so you don’t have to declare them aside.

you are trying to do this with multiple of the variable D1

D2

D3

Etc…

Each a different part

To give you some background the D= DecalPart 1 is the corresponding one, for example, DecalPart1, this is for a decal rent system and when I fire the server for the remote event I need to have the specific part to display the decal

What is the issue I don’t seem to be getting?

From the very first post, I guess that you are not deleting the “cache” that is storing the game’s id, it keeps it in it. Perhaps if you deleted the data number by turning it into a nil, like, whenever the player presses cancel, the game doesn’t just close the HUD, it also deletes the data with something like

local data = game.Workspace.IntValue.Value --the intvalue would be where the ID number, not the object, is stored
if playerclosedtheIDtab then
     closeIDtab()
     data = nil --this all is an example, not working scripts...

from the next one, the one @Wunder_Wulfe is pointing, it’s simply that you’re declaring a function inside a function, it looks like this

local function myfunction()
    print "Hello world!" --this would be the first function

Part.Touched:Connect(function() --this would be the second function
     myfunction() --this now is the function inside a function
end)

you can straight up change it to be one singular function doing all of that, if you don’t need to add anything else, which seems to me that you don’t…

local function myfunction()
    print "hello world!"
end

Part.Touched:Connect(myfunction)

OR

Part.Touched:Connect(function()
    print "hello world!"
end)

you would need the former, but you’re seeming to be doing the latter. You already made the local function up in the main area of the script, yet you call another function that you don’t need…

Thanks so much for the help, one last thing If I were to use what you said and have a string value in the explorer to store the current decal part how could I reference a child of that part if its stored as a string?
FFF

Could potentially a module work?

I don’t quite get what you mean, I need a bit more details.

I don’t have modules very clear in my mind, but as far as I know, module(scripts) are for storing variables, specially functions, that you can use in more than one script. If you use a module it would be for storing a single fraction of data like an important table or an useful function.

If what you’re storing is an ID, I believe you shouldn’t be storing it as a string, just an Int. Now, if it’s another thing what you mean, like a string part’s child, well you could make a stringvalue object in the workspace and put an empty decal as a child of that stringvalue, enter the ID for that decal, and probably referencing a child of that part would be possible;

now, I’m not entirely sure, my biggest skill is not programming, you can see that I’m the only one with a different title ITT. I understand some things about it, but it’s not my biggest strength, I believe if you could be more detailed I could understand

I just need to know if I were to use what you said and have a string value in the explorer to store the current decal part how could I reference a child of that part if its stored as a string? (Image reference above)

I believe I understand now. I need you to correct me if I’m wrong, but you want to “store the current decal id in a string value in an external part in the explorer, and then reference a child of that part but I can’t because it’s a string”.

You don’t need to reference the child of a string, you can just reference the child of the stringvalue object itself, by storing what you want to use (a decal in this situation) inside the stringvalue, you know, just dragging the decal inside the stringvalue object. And storing object inside object values is impossible. In the picture you mean the blue circle, which is showing me that what’s important is the data block inside the DS folder, which I can’t really connect with all this…

Also, on the image you’re making a value which must be a boolean (true or false) because you’re declaring if it’s false or not, but you’re talking about strings, which are word stores not true or false…

if game.Workspace.DS.data.Taken.Value == false then --[[value must be true or false, it's impossible for it to be a string because strings can't be true or false, just letters]]

No I meant the part that I will eventually display the decal on in a string, so I can then use it reference where to put the string onto, I need it in explorer as a string so the value doesn’t turn into a table, so I wanted to know how I can use the string value, and depending on the object in the string find its specific child.

Make a variable, to that variable you define the value of that stringvalue’s value

If it’s a specific string find the child INSIDE the stringvalue, not the stringvalue’s value. So you would be looking at an object’s child, not a value’s child. You really can’t look for the child of a value, just for the children of objects…

If i’m still not clear, tell me what would a player do if the script did work the way you intended. Like, what would the player experience

I think I’m going to completely restart my script how do you think I should re format it

So to give you a full explanation of what I’m trying to do, There are multiple parts where a decal can be stored like shown when one of these is clicked it pops up a gui asking if for the decal ID in a textbox then you have the choice of either pressing rent which fires the remote event changing the id for the decal on the part and subtracting the EP for the purchase and cancel obviously canceling the transaction the decal part would then change when the user leaves and another user buys it.
How would I go on on this?

I’m sorry man, scripting isn’t my biggest strength, and it’s not the time for me to write code. If I were you, I’d just make sure that when you cancel, the decal id gets deleted by inserting it into a nil value, so it doesn’t get stored in between cancelling…

1 Like