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

Vehicleseat camera not working after you use it once?

I don't get why this is happening. There's a local script parented to a server script, then parented to a vehicleseat. I'm trying to make an RC car. The first time the camera works good, but then the second time you use it, it just does not want to focus on the car. Why is this happening!? Serverscript:

print("Camera script loading")
local newscript = script.CameraChange:Clone()
script.Parent.ChildAdded:Connect(function(weld)
	if weld.Name == "SeatWeld" then
		local h = script.Parent.Occupant
		wait()
		if h.Sit == true then
			newscript.Parent = h.Parent	
		end  
	end
end)

localscript:

Camera = game.Workspace.CurrentCamera
Object = game.Workspace.HPIBlitz.HPIBlitz.Shell
Player = script.Parent.Humanoid
Camera.CameraSubject = Object
Camera.CameraType=3
while wait() do
	if Player.Sit == false then
	Camera.CameraSubject = Player
	script:Destroy()
	end
end

1 answer

You're cloning it one time and then the localscript gets destroyed, that's why it only works one time, maybe try to clone the localscript after line 7 in your server script.

5 comments

0

The clone gets sent to the player. The original copy of the script is uneffected.

0

The clone gets sent to the player. The original copy of the script is uneffected.

0

The clone gets sent to the player. The original copy of the script is uneffected.

0

In your server script you're clong the localscript one time, and then you parent it to the seat occupant. In the localscript, you're making sure that the player is sitting and if it's not, then you destroy the localscript itself. So again, in the server script, when someone sits you parent the localscript, but it's nil because it doesn't exists anymore.

1

nvm it works

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