#Need help knowing how to make it so camera is enabled when they sit in DriveSeat.

1 messages · Page 1 of 1 (latest)

next stone
#

so basically i have this script that when the player presses a keybind their camera is the "new" one in a different location, pretty much a first person camera. I'm trying to know if i could make instead of them pressing a keybind when they sit in the vehicles DriveSeat, it immediately goes to the camera?

#

uhh the script/code is too big

#

ahh got it

covert belfry
#

to have the camera change as soon as you sit, you could connect the touched event of the car. you do have to also check that whatever touches it is a player though:

car.DriveSeat.Touched:connect(function(OtherPart)
  Assembly = OtherPart.AssemblyRootPart.parent --for a player that resolves to the character model
  if Assembly == plr.character then
    if not debounce then
      debounce = true
      enableCam()
  end
end)

--note: when you disable the camera, you should also set the debounce back to false.
--you can't do it in the if statement because other wise you risk enabling the camera multiple times.
car.DriveSeat.ChildRemoved:connect(function(obj)
  if obj.Name == "SeatWeld" then 
    disableCam()
    if debounce then debounce = false end
  end
end)

Hope this helps!

next stone
covert belfry
#

the code i submitted just now will replace the last two lines of the original code - delete these:

car.DriveSeat.ChildRemoved:connect(function(obj)
  if obj.Name == "SeatWeld" then disableCam() end 
end)
UserInputService.InputBegan:Connect(handleInput)

and add the code i submitted

elfin cedarBOT
#

studio** You are now Level 1! **studio

next stone
#

sorry im really bad at scripting

covert belfry
#

it's fine, we all start somewhere. ill be taking the robux though. can we do 100?

next stone
#

it shows up underlined in red.

covert belfry
#

got it - i missed out on an end somewhere. try this

next stone
#

it still doesnt work for some reason

covert belfry
#

any errors?

next stone
covert belfry
#

but the camera wont change, right?

next stone
#

yep it doesnt change

covert belfry
#

do you have a copy of the place?

#

i would like to troubleshoot it.

next stone
covert belfry
#

new day, more time to troubleshoot.

#

ill get back to you in (hopefully) less than an hour.

covert belfry
#

ok, so i have something.

so turns out, the way the script is set up, the player will have sat before anything in the script can listen for the player entering. your best bet to having the camera work immediately would be to explicitly enable the debounce and call enableCam().