Basically what I want to do is improving a plane script. The plane script I use for my fighter planes allows them to do all maneuvers that a plane can do in real life, unlike other scripts. However, this script doesn't have any sounds for the weapons so what I want to do is when you sit in the pilot seat and press "C" (the gun button) you hear a cannon sound. I've figured out how to make something be triggered with a button, but I can't combine it with seats.
Well, simply use 'occupant' property of seats.
local UserInputService = game:GetService("UserInputService") local Player = game.Players.LocalPlayer --> Local script!! local Sound = game.SoundService.Sound local Seat = workspace:WaitForChild('Seat') -- Your seat Active = false function onInputBegan(input,gameProcessed) if input.KeyCode == Enum.KeyCode.C then if seat.Occupant and Seat.Occupant.Parent.Name == Player.Name then Active = true end end end function onInputEnded(input,gameProcessed) if input.KeyCode == Enum.KeyCode.C then if seat.Occupant and Seat.Occupant.Parent.Name == Player.Name then Active = false end end end Seat.Changed:Connect(function(Prop) if Prop == 'Occupant' then local Occupant = Seat.Occupant if Occupant then -- Nothing else Active = false --> Player left the seat end end end) UserInputService.InputBegan:connect(onInputBegan) UserInputService.InputEnded:connect(onInputEnded) while wait() do if Active == true then -- Code if Sound.IsPlaying == false then Sound:Play() end else if Sound.IsPlaying == true then Sound:Stop() end end end