drefusJoin Date: 2011-02-06 Post Count: 307 |
local player = game.Players.LocalPlayer
local char = player.Character
Output says:
Workspace.Charcter:2: attempt to index local 'player' (a nil value) |
|
|
Is this in a LocalScript in StarterPlayerScripts or StarterGUI or StarterPack? |
|
|
Add wait() in the beginning of you code before you start defining stuff |
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
IT is a script in workspace and would it be like
local player = game.Players.LocalPlayer
wait()
local char = player.Character |
|
LaeMVPJoin Date: 2013-06-24 Post Count: 4416 |
You can't get localplayer from a serverscript |
|
JoshRBXJoin Date: 2012-05-19 Post Count: 8778 |
Use a LocalScript.
Place it inside the player, so in StarterGUI for example.
|
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
Why not playercharcterscripts |
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
This is my script and it is a local script which is in starterplayerscripts but it dose nothing and the output dosen't say anything
local player = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function(player)
local pants = player.Character:FindFirstChild("Pants")
if pants ~= nil then
pants:Remove()
local clon = script.Parent:FindFirstChild("Pants"):Clone()
clon.Parent = player.Character
local shirt = player.Character:FindFirstChild("Shirt")
if shirt ~= nil then
shirt:Remove()
local clon = script.Parent:FindFirstChild("Shirt"):Clone()
clon.Parent = player.Character
local color = player.Character:FindFirstChild("BodyColors")
if color ~= nil then
color:Remove()
local clon = script.Parent:FindFirstChild("BodyColors"):Clone()
clon.Parent = player.Character
end
end
end
end) |
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
bump |
|
Jric0Join Date: 2015-02-12 Post Count: 658 |
the character is in the workspace, where the shirt/pants would be
if i'm right defining the CHARACTER rather than the player would be
game.Players.PlayerAdded:connect(function(player)
local char = game.Workspace:WaitForChild(player.Name)
--stuff here
end)
i might be wrong,¯\_(ツ)_/¯
good luck.
Jrico253 → iiJricoo → Jric0 |
|
Jric0Join Date: 2015-02-12 Post Count: 658 |
also, don't use that in a LocalScript or the clothes are only gonna be modified on the client's end and normal clothing will still look like normal on other people's screens.
Jrico253 → iiJricoo → Jric0 |
|
JoshRBXJoin Date: 2012-05-19 Post Count: 8778 |
If you haven't rewritten the error in the output, I'd like to make you aware of the fact that Character is spelled inorrectly.
|
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
It is a 1 player game and should the code look like this
game.Players.PlayerAdded:connect(function(player)
local char = game.Workspace:WaitForChild(player.Name)
local pants = char:FindFirstChild("Pants")
if pants ~= nil then
pants:Remove()
local clon = script.Parent:FindFirstChild("Pants"):Clone()
clon.Parent = char
local shirt = char:FindFirstChild("Shirt")
if shirt ~= nil then
shirt:Remove()
local clon = script.Parent:FindFirstChild("Shirt"):Clone()
clon.Parent = char
local color = char:FindFirstChild("BodyColors")
if color ~= nil then
color:Remove()
local clon = script.Parent:FindFirstChild("BodyColors"):Clone()
clon.Parent = char
end
end
end
end) |
|
Jric0Join Date: 2015-02-12 Post Count: 658 |
looks fine to me.
Jrico253 → iiJricoo → Jric0 |
|
drefusJoin Date: 2011-02-06 Post Count: 307 |
It wont work idk why |
|