Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Humanoidrootpart is not a valid member of Model?

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)

1 comment

0

Have you tried using CharacterAdded to obtain the character?

3 answers

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)

1 comment

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''

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) 

7 comments

0

this will not work because you put two vars in one line in line 07, and put frame.visible instead of frame.Visible

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'

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.

0

ok

0

Anasbahuddin it doesnt matter even though you put to variables in one line.

0

it worked for me

0

No problem, I'm always willing to help!

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.