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 local 'acplayer' (a nil value)?

Sorry for posting so often, but whenever I try my script that changes a player's skin color I get this error Players.UNBANhappyniceguy5.PlayerGui.Skin Color:5: attempt to index local 'acplayer' (a nil value)

local player = script.Parent.Parent
local acplayer = game.Workspace:FindFirstChild(player)
wait(1)

acplayer['Body Colors'].HeadColor = BrickColor.new('Pastel brown')

2 comments

0

local acplayer = game.Workspace:FindFirstChild(player.Name)

0

yes I tried that already but it doesn't work, says the same error

1 answer

✓ Accepted answer

It looks like you're using a serverscript. Try doing this if your game is filtering enabled:

  1. add a RemoteEvent to game.ReplicatedStorage and call it ColorEvent

  2. add a localscript on the starter gui

  3. add a serverscript on the workspace

  4. in the localscript add this

game.ReplicatedStorage.ColorEvent:FireServer()
  1. in the serverscript add this
game.ReplicatedStorage.ColorEvent.OnServerEvent:Connect(function(acplayer)
acplayer.Character['Body Colors'].HeadColor = BrickColor.new('Pastel brown') -- You forgot to put in "Character"!
end)

If your game is experimental mode (I don't recommend) then just turn the script into a LocalScript.

Also if you didn't know ServerScript = a normal script

For more info on roblox wiki visit this: https://wiki.roblox.com/index.php?title=API:Class/Workspace/FilteringEnabled

6 comments

0

Am I just dumb? I get a Attempt to connect failed: Passed value is not a function error

0

Hold on I'm going to test the script and see if it fully works if it doesn't I can edit it.

0

Ohh. You also can't just do player["body colors"], you must do player.Character["Body Colors"](Try out my edited answer)

0

I tried acplayer.Character['Body Colors'].HeadColor = BrickColor.new('Pastel brown') but it still gives that passed value is not a function error

0

There are a few questions to ask before going deeper: 1. Is your game Filtering Enabled? 2. Did you follow the instructions? 3. Did you close the function with a ')' ? 4. Am I clear? I need to make sure XD | And the script worked pretty well for me.

0

it has something to do with r15 and r6, in r15 it works but not with r6

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