I am trying to make a player change their character appearance to a ball but I am getting a weird error.
local dontrepeat
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, rig)
local char = plr.Character
print(rig)
--next line has the error
if not game.Workspace:FindFirstChild(rig).HumanoidRootPart:FindFirstChild("DontRepeat") then
plr.Character = workspace:FindFirstChild(rig)
end
wait()
if not workspace:FindFirstChild(rig).HumanoidRootPart:FindFirstChild("DontRepeat") then
dontrepeat = Instance.new("Attachment")
dontrepeat.Name = "DontRepeat"
dontrepeat.Parent = workspace:FindFirstChild(rig).HumanoidRootPart
wait()
char:Destroy()
end
end)
I also fired the remote event from a local script using this:
wait(3)
local plr = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local rig = game.ReplicatedStorage.ballData:FindFirstChild(plr:WaitForChild("playerData"):WaitForChild("EquippedBall").Value).StarterCharacter:Clone()
rig.Parent = workspace
rig.Name = plr.Name.."Rig"
camera.CameraType = "Follow"
camera.CameraSubject = rig.HumanoidRootPart
script.Parent.RemoteEvent:FireServer(rig.Name)
The error I kepp getting is
Players.Zer0Cactus.PlayerGui.CharacterMorph.Script:13: attempt to index nil with 'HumanoidRootPart' - Server - Script:13
I feel like this shouldn’t be happening so is there something I am missing? Thank you!