Help with code error

I have mostly no experience to scripting so what is on this code wrong? Can anyone help please so that everyone in the game can hear the plane sounds? Thank you for your help :slight_smile:

local Sound = script.Parent.Parent.Engine.Sound
local On = script.Parent.On
local Throttle = script.Parent.Throttle
local ThrottleIncrase = 0

------You can change these------
local BasePitch = 1
local MaxPitch = 1.95
local IncreaseAmount = 0.6

script.Parent.EngineFE.OnServerEvent:Connect(function()
while wait() do
if ThrottleIncrase ~= Throttle.Value then – Makes sound increase delayed
if ThrottleIncrase < Throttle.Value then
ThrottleIncrase = ThrottleIncrase + IncreaseAmount
elseif ThrottleIncrase > Throttle.Value then
ThrottleIncrase = ThrottleIncrase - IncreaseAmount
end
end
Sound.Pitch = BasePitch + (MaxPitch - BasePitch) * ThrottleIncrase / 100
if On.Value == true then
Sound:Resume()
else
Sound:Stop()
end
end)

Whats the problem with the script? it runs? any errors in output? any sound plays?

Thats a server script, looks like you are triggering that script from a RemoteEvent called EngineFE right? And you are doing that from a local script by EngineFE:FireServer() right?

The sound instance is placed in the parent of the parent of the server script (wheres that?) If the sound is parented to a Part in workspace it will play as 3d sound coming out from that part. If you want the sound to be global, the sound should not be parented to a Part, try using a folder or model instead, or use it from SoundService to play it locally on client side.

The error I see in your script is that is missing an end

local Sound = script.Parent.Parent.Engine.Sound
local On = script.Parent.On
local Throttle = script.Parent.Throttle
local ThrottleIncrase = 0

------You can change these------
local BasePitch = 1
local MaxPitch = 1.95
local IncreaseAmount = 0.6

script.Parent.EngineFE.OnServerEvent:Connect(function()
	while wait() do
		if ThrottleIncrase ~= Throttle.Value then -- Makes sound increase delayed
			if ThrottleIncrase < Throttle.Value then
				ThrottleIncrase = ThrottleIncrase + IncreaseAmount
			elseif ThrottleIncrase > Throttle.Value then
				ThrottleIncrase = ThrottleIncrase - IncreaseAmount
			end
		end
		Sound.Pitch = BasePitch + (MaxPitch - BasePitch) * ThrottleIncrase / 100
		if On.Value == true then
			Sound:Resume()
		else
			Sound:Stop()
		end
	end -- THIS END WAS MISSING
end)

When posting in DevForum, try to use the format tool to enclose your script so others can read it easily.

if your trying to move them smoothly, use tweens instead, and if that doesnt work, replace the sound and move the assetID over

It sould be used as a plane sound when turning the engine on. Like when you select the tool with β€˜β€˜E’’. I do have a script that works but its a script so only the pilot can hear the engine sounds and thats the problem. I dont have very good knowlege for scripting so this is a bit hard for me. Here is a picture of it and the script files…
Bild_2023-01-15_204532796
Sound scripts (Change from local hearing to everyone).rbxm (1,6 KB)

use a local script, and activate the sound using this line of code (assuming its a clickdetector)

"Your Clickdetector".MouseClick:Connect(function()
"Sound Here":Play()
end)

if theres a red line under ) at the end part of the script, then remove it

where it says "your blah blah", remove the "" as well

heres some example paths:

for the engine part

workspace.Plane.Engine.Sound

for the clickdetector part

workspace.Plane.Soundmaker.Clickdetector

^^ ONLY EXAMPLES ^^