Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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?

0
This is a LocalScript right? sheepposu 561 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Ad

Answer this question