Hello,
I tried to ask at scriptinghelpers.org, I didn’t get an answer.
I want help with this:
How can I make a horn in the vehicleseat that when you press a “H” key, it will make a sound and players near me will hear a sound.
I tried all the tutorials I found on devforum or on youtube, but none of them worked.
FilteringEnabled is enabled so I dont know where is the problem.
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
local HumanoidRootPart = character.HumanoidRootPart
local seat = workspace.Car.VehicleSeat -- Change this to your vehicle seat
local RE = game.ReplicatedStorage.RemoteEvent
local function onInputBegan(input, gameProcessed)
if not gameProcessed and input.KeyCode == Enum.KeyCode.H then
if (HumanoidRootPart.Position - seat.Position).Magnitude < 20 then
RE:FireServer()
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)
Server Script:
local seat = workspace.Car.VehicleSeat -- Change this to your vehicle seat
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
seat.HonkSound:Play() -- Change this to your honk sound
end)