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

HumanoidRootPart is not a valid member of model?

Asked by 5 years ago

So i am trying to make a Keybind door, E to topen, it works, but the "E" image doesn't show up and i guess it is because of this error at line 21.

local inputservice = game:GetService("UserInputService")

inputservice.InputBegan:connect(function(i,g)
    if i.UserInputType == Enum.UserInputType.Keyboard then
        if i.KeyCode == Enum.KeyCode.E then
            for _,Door in pairs(workspace.Doors:GetChildren()) do
                local Mag = (Door.Center.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
                if Mag <= Door.Range.Value then
                    Door.Event:FireServer()
                    break
                end
            end
        end
    end
end)


while true do
    script.Parent.ImageLabel.Visible = false
    for _,Door in pairs(workspace.Doors:GetChildren()) do
        local Mag = (Door.Center.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
        if Mag <= Door.Range.Value then
            local D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(Door.Center.Position)
            script.Parent.ImageLabel.Visible = true
            script.Parent.ImageLabel.Position = UDim2.new(0,D3ToD2.X,0,D3ToD2.Y,0)
            break
        end
    end
    wait()
end
0
the humanoid rootpart probarly didnt load yet, do `.Character:WaitForChild ("HumanoidRootPart") starmaq 1290 — 5y
0
that solved it, thanks! blokskesman -8 — 5y
0
This is a copied script, seen it before SuperSamyGamer 316 — 5y

Answer this question