Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a script that plays a sound when moving while in vehicle seat?

I tried making a script that plays a sound when moving while in a vehicle seat, but it isn't working so help is appreciated.

Script:

while wait() do
	if script.Parent.Throttle == 1 then
		script.Parent.Run:Play()
	else
		script.Parent.Run:Pause()
	end
end

3 comments

0

you got there a sounds thing

0

Never use wait() it's really bad for performance instead use game.RunService.Heartbeat:Wait() waiting for events to be fired is a lot better. There's always an event for different situations. Is this your entire script?

0

i gave you an answer

1 answer

I really don't know, or think this is the best way of over coming your problem, but you can just check to see if the player is touching the part I guess. Put this script in your seat, and put your sound script where it says in this script.


 

local seat= script.Parent
 

local function onTouch(otherPart)

	local character = otherPart.Parent
 

	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
 
	if humanoid then
		---your sound script.
	end
end
 
seat.Touched:Connect(onTouch)

1 comment

0

I am new to scripting so I don't know how

This discussion is preserved as it was. New answers, comments, and votes are closed.