Hello, I am a very new developer and want to add a sound effect to a player every time it sits. But I just don’t know what to do, I’ve tried looking at tutorials and figuring it out by myself but nothing seems to work. I’d appreciate some help.
1 Like
A simple solution would be to check when the property Sit
is set to true.
[Put this in a local script]
local player = game:GetService("Players").LocalPlayer
local Char = player.Character or player.CharacterAdded:Wait()
local humanoid = Char.Humanoid
local sound = game.Workspace.MySound
humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
if humanoid.Sit == true then
sound:Play()
end
end)
But if you know the seats, and have them -
you could use -
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if thing.Occupant ~= nil then
if thing:FindFirstChild("Working") then
end
end
end)
2 Likes
You could use the humanoid.Sit boolvalue to detect when the player sits down:
humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
if humanoid.Sit == true then
sound:Play()
end
end)
1 Like
Do I have to put the sound that I want to play in a specific place like SoundService?
The first script he showed would go in StarterPlayerScripts
(LocalScript)
You could probably just parent the sound to the character’s HumanoidRootPart, for example. Make sure the volume is good and that it has the sound id. Then when the sound effect is done playing, you just destroy it. There are probably many better ways to do it, but this is all I can think of.