Hello,
So I made a periscope. Unfortunately it is not yet working perfectly. It uses a VehicleSeat to control the rotation / swivel of the periscope, and the camera is changed via a RemoteEvent and local script. The player can’t walk onto the VehicleSeat, as it’s disabled, and instead triggered by a ProximityPrompt.
The main issue is that about 50% of the time, I activate the ProximityPrompt, and the player is teleported to the VehicleSeat (but not seated on it), and free to walk away. When the player returns within range of the prompt, they are automatically seated in the seat, and using the periscope. Not only am I asking if anyone can point out why this is happening, but also is there a more efficient way to do this? Sorry about the long post, and thanks in advance for any help whatsoever! Here is the script:
ProximityPrompt Server Script (Sibling of the ProximityPrompt)
local VehicleSeat = script.Parent.Parent:FindFirstChild("VehicleSeat") -- Adjust the path to the VehicleSeat
if not VehicleSeat then
warn("VehicleSeat not found")
return
end
local ProximityPrompt = script.Parent:FindFirstChildOfClass("ProximityPrompt")
if not ProximityPrompt then
warn("ProximityPrompt not found")
return
end
local seatOccupantConnection = nil
local function onSeatOccupantChanged()
if not VehicleSeat.Occupant then
VehicleSeat.Disabled = true
if seatOccupantConnection then
seatOccupantConnection:Disconnect()
seatOccupantConnection = nil
end
end
end
ProximityPrompt.Triggered:Connect(function(player)
if not VehicleSeat.Occupant then
VehicleSeat.Disabled = false -- Enable the seat
-- Teleport the player's character to the VehicleSeat
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
character:SetPrimaryPartCFrame(VehicleSeat.CFrame)
end
-- Disconnect any existing connection and set up a new one
if seatOccupantConnection then
seatOccupantConnection:Disconnect()
end
seatOccupantConnection = VehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(onSeatOccupantChanged)
end
end)
I don’t see where you are actually putting the player in the seat with the :Sit() function?
Are you just teleporting and hoping they move to trigger the sitting?
That didn’t work either unfortunately. I’m not sure if a player can sit in a disabled seat, and if they are sitting in it when it becomes disabled, they would get kicked off automatically no? That’s what I thought the issue was when I tried it anyways.
You can’t manually assign the SeatPart property, you can only read from it.
It gets assigned when you use the :Sit() command, or I think it might get assigned also if you simply put
a SeatWeld, but not sure on that.
If you’d like I have a seat script I got from the toolbox years ago that allows you to position the player on the vehicleseat (welded as per usual) and edit their arms/legs/head/sitting position parameters so you could have them in a standing pose instead while using it.
It’s for R6 but it could be modified for R15 too.
The player would have to jump to get off the seat still, but the seat still registers throttle and steering inputs.
I can get it for you later tonight if you’d like.
No need, much appreciated though. The animation I have handles the player’s pose when they’re using the periscope. I have yet to work out the player leaving the seat without jumping, but I’m sure that won’t be too difficult. Thank you very, very much for your help!