I'm trying to make an RC car, but the camera doesn't work. I get the error attempt to index nil with 'HPIBlitz'. What does this mean? How do I fix it? Localscript:
Camera = game.Workspace.CurrentCamera
LocPlayer = game.Players.LocalPlayer
for _, v in pairs(workspace:GetDescendants()) do
if v.Name == LocPlayer.Character.Name .. "'s car" then
Object = v
end
end
Vehicle = Object.HPIBlitz.Shell
Player = script.Parent.Humanoid
Camera.CameraSubject = Vehicle
Camera.CameraType=3
if Player.Sit == false then
Camera.CameraSubject = Player
Camera.CameraType = Enum.CameraType.Custom
script:Destroy()
end
--This is parented to the server script.
Server script:
print("Camera script loading")
script.Parent.ChildAdded:Connect(function(weld)
if weld.Name == "SeatWeld" then
local h = script.Parent.Occupant
wait()
if h.Sit == true then
local newscript = script.CameraChange:Clone()
newscript.Parent = h.Parent
end
end
end)
Change name of the model:
local seat = script.Parent.rrccccc
seat.ChildAdded:Connect(function(weld)
if weld.Name == "SeatWeld" then
local h = seat.Occupant
wait()
if h.Sit == true then
script.Parent.Name = h.Parent.Name .. "'s car"
end
end
end)
--Server script
Remove name of the model:
local seat = script.Parent.rrccccc
seat.ChildRemoved:Connect(function(weld)
script.Parent.Name = "HPIBlitz"
end)
--Server script
