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

Player's camera breaks when you die/reset?

Asked by 3 years ago

Help, I'm making an RC car game. When you use the RC car without death it works like normal. But when you reset/die, the vehicle camera completely breaks and it is stuck at the place you died. When you go into a car, it just does this weird eye-breaking thing where your screen flickers and let's just say that was not a good experience. The scripts are parented to a vehicleseat. First there's a server script inside the vehicleseat, then there's a localscript parented to the server script.

ServerScript:

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)

LocalScript:

Camera = game.Workspace.CurrentCamera
Object = game.Workspace.Toyota.Toyota.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
0
Answered by 3 years ago

I've fixed it, the while wait() loop wasn't necessary, I deleted it and it works now.

Ad

Answer this question