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

attempt to index local 'acplayer' (a nil value)?

Asked by 5 years ago

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')
0
local acplayer = game.Workspace:FindFirstChild(player.Name) awesomeipod 607 — 5y
0
yes I tried that already but it doesn't work, says the same error UNBANhappyniceguy5 52 — 5y

1 answer

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

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

  1. add a localscript on the starter gui

  2. add a serverscript on the workspace

  3. 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

0
Am I just dumb? I get a Attempt to connect failed: Passed value is not a function error UNBANhappyniceguy5 52 — 5y
0
Hold on I'm going to test the script and see if it fully works if it doesn't I can edit it. mudathir2007 157 — 5y
0
Ohh. You also can't just do player["body colors"], you must do player.Character["Body Colors"](Try out my edited answer) mudathir2007 157 — 5y
0
I tried acplayer.Character['Body Colors'].HeadColor = BrickColor.new('Pastel brown') but it still gives that passed value is not a function error UNBANhappyniceguy5 52 — 5y
View all comments (2 more)
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. mudathir2007 157 — 5y
0
it has something to do with r15 and r6, in r15 it works but not with r6 UNBANhappyniceguy5 52 — 5y
Ad

Answer this question