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:
1 | local character = game.Players.LocalPlayer.CharacterAdded:Wait() |
2 | script.Parent.MouseButton 1 Click:Connect( function () |
3 | if character:FindFirstChild( "HumanoidRootPart" ) then |
4 | character.HumanoidRootPart.CFrame = CFrame.new(workspace.respawn.position) |
5 | end |
6 | end ) |
Other LocalScript
01 | local frame = script.Parent.Parent.frame |
02 | local open = false |
03 |
04 | script.Parent.MouseButton 1 Click:Connect( function () |
05 | if frame.Visible = = false then |
06 | frame.Visible = true |
07 | else |
08 | frame.Visible = false |
09 | end |
10 | end ) |
You need to wait for character and the HumanoidRootPart
incase it isn't loaded in yet
01 | local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() |
02 |
03 | script.Parent.MouseButton 1 Click:Connect( function () |
04 | character:WaitForChild( "HumanoidRootPart" ).Cframe = CFrame.new(workspace.respawn.position) --//Also It should be HumanoidRootPart not Humanoidrootpart and you had a problem with the CFrame |
05 | end ) |
06 |
07 | local frame = script.Parent.Parent.frame local open = false |
08 |
09 | script.Parent.MouseButton 1 Click:Connect( function () |
10 | if frame.Visible = = false then |
11 | frame.Visible = false |
12 | else |
13 | frame.Visible = false |
14 | end |
15 | 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.
1 | wait() |
2 | character = game.Players.LocalPlayer.Character script.Parent.MouseButton 1 Click:Connect( function () character.HumanoidRootPart.Cframe = CFrame.new(workspace.respawn.position) |
3 | end ) |