local player = game.Players.LocalPlayer
local plot
local function MoveChar(char)
wait(0.1)
char:SetPrimaryPartCFrame(CFrame.new(plot.Plot.Spawn.CFrame.X,plot.Plot.Spawn.CFrame.Y + 5, plot.Plot.Spawn.CFrame.Z))
end
player.CharacterAdded:Connect(function(char)
for i,v in pairs(workspace.Plots:GetChildren()) do
if v then
if v.Plot.Owner.Value == player then
plot = v
MoveChar()
break
end
end
end
end)
COMMUNITY QUESTION
attempt to index local 'char' (a nil value) why is this happening?
2 answers
The reason your code is not working as you are not sending over the "Char" as an argument when running your custom funtion. Thats an easy fix. Use this:
local player = game.Players.LocalPlayer
local plot
local function MoveChar(char)
wait(0.1)
char:SetPrimaryPartCFrame(CFrame.new(plot.Plot.Spawn.CFrame.X,plot.Plot.Spawn.CFrame.Y + 5, plot.Plot.Spawn.CFrame.Z))
end
player.CharacterAdded:Connect(function(char)
for i,v in pairs(workspace.Plots:GetChildren()) do
if v then
if v.Plot.Owner.Value == player then
plot = v
MoveChar(char)
break
end
end
end
end)
dosent player.CharacterAdded only fire on the server? if not my bad
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
i did not notice it tnx