|
| 14 Sep 2014 10:23 PM |
Question, does anyone know how to make a Part play an audio once stepped on?
Say like the part material is sand, and I want a sand audio to play once you are stepping on it. How do I make the audio play while a player is walking on the part.?
(Plus, I didn't know if this should have been posted in builder helpers or Scripting Helpers).
Thanks! |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 14 Sep 2014 10:27 PM |
A. Create a walking animation B. Name the Keyframe where the legs should hit the ground something C. Whenever the AnimationTrack runs that KEYFRAME, Raycast under the legs D. Play the sound depending if it hits or not and what material it does hit. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 14 Sep 2014 10:48 PM |
local mat={["Sand"]=game.Workspace.Sand}--Add more local touched={"Part1","Part2"} for i,v in pairs(touched) do v.Touched:connect(function(hit) for index,x in pairs(mat) do if v.Material==index then local player=game.Players:GetPlayerFromCharacter(hit.Parent) local sound=x:Clone() sound.Parent=player.PlayerGui sound:Play() end end end) end |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 14 Sep 2014 10:52 PM |
Touched is so bad at not running multiple times AND detecting when something touches something.
There's a reason why I said to Raycast instead. |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
| |
|