Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

OnSeat Engine Sound ?

Asked by 9 years ago

I am trying to create a function where when the player sits; the sound is activated. Until he "jumps" off the seat, which will disable the sound. But for some reason it's not working and not displaying any errors in the Output. Is there something i'm doing wrong?

function onChildAdded(child)
if child.Name == "SeatWeld" then
if child.Part1.Name == "Torso" then
local player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
if player ~= nil then
script.Parent.Engine:Play()
end
end
end
end

function onChildRemoved()
script.Parent.Engine:Stop()
end

script.Parent.ChildAdded:connect(onChildAdded)
script.Parent.ChildRemoved:connect(onChildRemoved)

Answer this question