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