I printed the character of the player I assigned the script to, and it didn’t error. Yet when I use the script it errors.
Magic.Player was defined as game.Players.gameowner101
This is the function.
This only happens when I use the command line, everything works just as intended when I use anything else to use the function and fill in the variables.
you could get the character directly, by workspace[username]
That would force me to change up the script and then change it back to normal.
In the image you sent, the Magic.Player is set to nil.
Yeah, it gets defined by the command on the command line you can see it int he first picture.
Blast.Player = game.Players.gameowner101
Exozorcus
(Exozorcus)
October 14, 2024, 8:01am
6
your character doesnt exist while you arent playing the game
are you running this during playtesting?
Well can you try this:
Magic.Player = game.Players:GetPlayerFromCharacter(workspace["gameowner101"])
Yeah, I am running it during playtesting.
Exozorcus
(Exozorcus)
October 14, 2024, 8:03am
9
try printing Player at the start of the spells function
It is in fact, printing nil… how would I fix that?
Exozorcus
(Exozorcus)
October 14, 2024, 8:06am
11
well if player is printing nil then you probably arent defining the variable in the metable correctly
how does the script work normally?
In any situation in which I am defining the player as long as it’s not the command line it works perfectly fine.
The module works by first of all, creating a player variable which is equal to nil, whenever the module runs, a script defines the player as the player that is using it, then runs every command with that player’s name.
That’s what i actually stated to you above, have you tried m script?
Exozorcus
(Exozorcus)
October 14, 2024, 8:08am
15
well, yeah, but its still defining the player explicitly so it should still work fine
The issue here is that when you set Magic.Player
, the local variable Player
has already been set on require.
Exozorcus
(Exozorcus)
October 14, 2024, 8:09am
17
it will probably work, but they want Magic.Player to be defined properly during playtesting
1 Like
Same error,
local Blast = require(game.ServerStorage.MagicModule) Blast.Player = game.Players:GetPlayerFromCharacter(workspace.gameowner101) Blast.Spells.Blast()
Exozorcus
(Exozorcus)
October 14, 2024, 8:10am
19
arent you overwriting it with the redefinition?
It is best practice not to create local variables for stuff like this and instead just use Magic.Player
in place of Player
.
Can you put your user in this format [“idk”]