Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to Index nil with 'Character' error, how do I fix this?

replicatedstorage.Remotes.Rank.OnServerInvoke = function()
	local character = game.Players.LocalPlayer.Character --This is the line with the error
	if not remoteData:FindFirstChild(character) then return "NoFolder" end
	
	local rank = player.leaderstats.Rank
		

I'm getting index nil and I do not know how to fix this. Any help?

1 comment

0

This is a LocalScript right?

1 answer

✓ Accepted answer

Okay, well you can't get a localplayer from a Script, but you can call the player from the parameters inside of the OnServerInvoke event.

Should look like this

replicatedstorage.Remotes.Rank.OnServerInvoke = function(player)

so then you can get the Character with local Character = player.Character

This discussion is preserved as it was. New answers, comments, and votes are closed.