This script gives the error: HumanoidRootPart is not a valid member of Model. When I print the 'char' it gives me my username (zomspi). This script runs when the character dies, when I die it runs that error.
wait(0.1)
local char = game.Workspace[script.Parent.Parent.Name]
local hrp = char.HumanoidRootPart
while true do
wait(1)
if (script.Parent.Position - hrp.Position).magnitude < 30 then
local nextlevel = math.random(1, #game.ServerStorage.Levels:GetChildren())
local level = game.ServerStorage.Levels:FindFirstChild(nextlevel):Clone()
level.Parent = script.Parent.Parent
level:SetPrimaryPartCFrame(script.Parent.Parent.PrimaryPart.CFrame + Vector3.new(0,0,-53))
wait(0.25)
if script and script.Parent then
script.Parent:Destroy()
end
break
end
end
Thanks!
EDIT: I figured out 'char' is equal to the name of my character, not my character, I still don't know how to fix it or why it's getting the name and not the character / model.
