I am trying to make a Script play a Sound when you sit on the Seat, but it will not work.
function onTouched(hit) if hit.Parent:findFirstChild("Humanoid") then local pl = game.Players:GetPlayerFromCharacter(hit.Parent) wait() I = Instance.new("Sound",Workspace) I.SoundId = "http://www.roblox.com/asset/?id=142435510" I.Volume = 0.7 I.Pitch = 1 end end script.Parent.Touched:connect(onTouched)
It's better to check for a weld using ChildAdded, because you don't always sit when you touch a sit brick.
local sp = script.Parent sp.ChildAdded:connect(function(weld) I = Instance.new("Sound", Workspace) I.SoundId = "http://www.roblox.com/asset/?id=142435510" I.Volume = 0.7 I.Pitch = 1 I:Play() while true do if not sp:findFirstChild(weld.Name) then I:Stop() I:Destroy() break end wait() end end)