I want to make a script that loads a require script when a button is pressed with given values.
I tried to make the script when the button is pressed be:
id = script.Parent.Parent.Id.Text
plr = script.Parent.Parent.Player.Text
require(id).load(player)
And yes it’s a normal script, and the code doesn’t give any errors but it doesn’t do anything either.
Yep, that should work. Make sure if the modulescript needs the player name or the player instance itself. If it needs player name, that should work. Otherwise, get the player object from Players service and send it in as a parameter.
You should use a local script to get inputs from the UI. To make this work, you would have to fire a remote to the server asking to require the specific module.
For the first one, when you do require(), you pass in a number as an int value. For the second one, you pass in a string value instead of an int. So to fix this just convert the string to int like int = tonumber(string).
tonumber returns nil if its argument could not be converted into a number. So something like 4959s would return nil since there is a non-number (the letter “s”).
And keep in mind that you can’t require by ID on the client, only the server can. Are you sure you need to do it this way? Why not just import the module into your game so it can be used without requiring by ID?