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 4 years ago

hi im working on a exit button for in a car for in a camping game but when I click on it it says humanoidrootpart is not a valid member of model here are the 2 local script I use

character = game.Players.LocalPlayer.character script.Parent.MouseButton1Click:Connect(function() character.Humanoidrootpart.Cframe.new(workspace.respawn.position) end)

local frame = script.Parent.Parent.frame local open = false

script.Parent.MouseButton1Click:Connect(function() if frame.visible ==false then frame.visible = false else frame.visible = false end end)

0
Have you tried using CharacterAdded to obtain the character? DeceptiveCaster 3761 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

It's because lua is case-sensitive and its HumanoidRootPart and not Humanoidrootpart, also you are changing the CFrame wrong, so change it to:

local character = game.Players.LocalPlayer.CharacterAdded:Wait()
script.Parent.MouseButton1Click:Connect(function() 
    if character:FindFirstChild("HumanoidRootPart") then                 
        character.HumanoidRootPart.CFrame = CFrame.new(workspace.respawn.position)
    end
end)

Other LocalScript

local frame = script.Parent.Parent.frame
local open = false

script.Parent.MouseButton1Click:Connect(function()
    if frame.Visible == false then
        frame.Visible = true
    else 
        frame.Visible = false
    end
end)
0
it says this:'16:22:44.921 - Players.topsporter2007.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:2: Expected identifier when parsing expression, got '02' 16:22:44.922 - Players.topsporter2007.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:2: Expected identifier when parsing expression, got '2'' topsporter2007 -4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You need to wait for character and the HumanoidRootPart incase it isn't loaded in yet

local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

script.Parent.MouseButton1Click:Connect(function()
    character:WaitForChild("HumanoidRootPart").Cframe = CFrame.new(workspace.respawn.position) --//Also It should be HumanoidRootPart not Humanoidrootpart and you had a problem with the CFrame
end)

local frame = script.Parent.Parent.frame local open = false

script.Parent.MouseButton1Click:Connect(function()
    if frame.Visible ==false then
        frame.Visible = false 
    else 
        frame.Visible = false 
    end
end) 
0
this will not work because you put two vars in one line in line 07, and put frame.visible instead of frame.Visible AnasBahauddin1978 715 — 4y
0
it says this :'16:19:59.763 - Players.topsporter2007.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:2: Expected identifier when parsing expression, got '08' 16:19:59.764 - Players.topsporter2007.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:2: Expected identifier when parsing expression, got '02' topsporter2007 -4 — 4y
0
That's because you are copying and pasting it, and the numbers they come with it when you copy and paste it. So delete the numbers. maxpax2009 340 — 4y
0
ok topsporter2007 -4 — 4y
View all comments (3 more)
0
Anasbahuddin it doesnt matter even though you put to variables in one line. JesseSong 3916 — 4y
0
it worked for me topsporter2007 -4 — 4y
0
No problem, I'm always willing to help! maxpax2009 340 — 4y
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Lua is case sensitive make sure your capitalisation is correct as followed and this will only work with R15 also make sure you publish it.

wait()
character = game.Players.LocalPlayer.Character script.Parent.MouseButton1Click:Connect(function() character.HumanoidRootPart.Cframe = CFrame.new(workspace.respawn.position) 
end)

Answer this question