Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Vehicleseat camera not working after you use it once?

Asked by 3 years ago

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

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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.

0
The clone gets sent to the player. The original copy of the script is uneffected. squidiskool 208 — 3y
0
The clone gets sent to the player. The original copy of the script is uneffected. squidiskool 208 — 3y
0
The clone gets sent to the player. The original copy of the script is uneffected. squidiskool 208 — 3y
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. Xx_XSanderPlayXx 160 — 3y
1
nvm it works squidiskool 208 — 3y
Ad

Answer this question