#Why is this sound effect not playing?
20 messages · Page 1 of 1 (latest)
SCRIPT 2 (Car - body normal script) local stopEvent = Instance.new("RemoteEvent", script.Parent)
stopEvent.Name = "StopEvent"
local alert = script.Parent.snsr1 -- First sensor (warning)
local stop = script.Parent.snsr2 -- Second sensor (braking)
local pt1 = script.Parent.stoppart -- First stopping part
local pt2 = script.Parent.stoppart2 -- Second stopping part
local disabled = false
-- 🚨 Alert System (Fires event when an object is detected)
alert.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
stopEvent:FireClient(player, "alert") -- Play warning sound only for this player
end
end)
-- 🛑 Stopping System (Stops the car & Notifies Player)
stop.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
stopEvent:FireClient(player, "stop") -- Play stop sound only for this player
end
-- Prevent multiple triggers
if disabled then return end
disabled = true
print("🛑 Braking Activated!")
-- Move pt1 to car position & enable collision
pt1.Position = script.Parent.Parent.DriveSeat.Position
pt1.CanCollide = true
pt2.CanCollide = true
-- ⚠️ Force Stop the Car (Stops globally for everyone)
local car = script.Parent.Parent
if car and car.PrimaryPart then
car.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
car.PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
end
-- Wait & release brakes
task.wait(4)
pt1.Position = pt2.Position
pt1.CanCollide = false
pt2.CanCollide = false
print("🚗 Brakes Released")
-- Allow braking again after delay
task.wait(2)
disabled = false
end)
You didn't clone it and parent it to the workspace or car.
let me try that
-- Ensure RemoteEvent exists in ReplicatedStorage
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteFolder = replicatedStorage:FindFirstChild("Test1")
if not remoteFolder then
remoteFolder = Instance.new("Folder")
remoteFolder.Name = "Test1"
remoteFolder.Parent = replicatedStorage
end
local stopEvent = remoteFolder:FindFirstChild("StopEvent")
if not stopEvent then
stopEvent = Instance.new("RemoteEvent")
stopEvent.Name = "StopEvent"
stopEvent.Parent = remoteFolder
end
local alert = script.Parent.snsr1 -- First sensor (warning)
local stop = script.Parent.snsr2 -- Second sensor (braking)
local pt1 = script.Parent.stoppart -- First stopping part
local pt2 = script.Parent.stoppart2 -- Second stopping part
local disabled = false
-- 🚨 Alert System (Fires event only for the player who triggered it)
alert.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
stopEvent:FireClient(player, "alert") -- Only play sound for this player
end
end)
-- 🛑 Stopping System (Stops the car & Notifies Player)
stop.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
stopEvent:FireClient(player, "stop") -- Only stop for this player
end
-- Prevent multiple triggers
if disabled then return end
disabled = true
print("🛑 Braking Activated!")
-- Move pt1 to car position & enable collision
pt1.Position = script.Parent.Parent.DriveSeat.Position
pt1.CanCollide = true
pt2.CanCollide = true
-- 🚗 Wait & release brakes
task.wait(4)
stopEvent:FireClient(player, "release") -- Only release brakes for this player
pt1.Position = pt2.Position
pt1.CanCollide = false
pt2.CanCollide = false
print("🚗 Brakes Released")
-- Allow braking again after delay
task.wait(2)
disabled = false
end)
local stopEvent = game.ReplicatedStorage:WaitForChild("Test1"):WaitForChild("StopEvent")
local sound = script.Parent:FindFirstChild("wng") -- Warning sound
local stopSound = script.Parent:FindFirstChild("stp") -- Stopping sound
local warningActive = false -- Prevent multiple warnings
stopEvent.OnClientEvent:Connect(function(action)
print("🎧 AEB Sound Event Received:", action) -- Debugging (CHECK OUTPUT)
if action == "alert" then
print("⚠️ Playing Warning Sound")
if sound and not warningActive then
warningActive = true
sound:Play()
task.wait(0.5)
sound:Play()
task.wait(2)
warningActive = false
end
elseif action == "stop" then
print("🛑 Playing Stop Sound")
if stopSound then
stopSound:Play()
end
-- 🛑 Stop only this player's car (not global)
local car = script.Parent.Parent
if car and car.PrimaryPart then
car.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
car.PrimaryPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
end
elseif action == "release" then
print("🚗 Stopping Sound")
if stopSound then
stopSound:Stop()
end
end
end)
@snow reef I still dont understand it, could you join me in studio?
** You are now Level 2! **
Sure. My user is PompyLou
hello?