add gs
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
|
||||
<External>null</External>
|
||||
<External>nil</External>
|
||||
<Item class="Script" referent="RBX0">
|
||||
<Properties>
|
||||
<bool name="Disabled">false</bool>
|
||||
<Content name="LinkedSource"><null></null></Content>
|
||||
<string name="Name">Sound</string>
|
||||
<string name="Source">-- util
|
||||
|
||||
function waitForChild(parent, childName)
|
||||
local child = parent:findFirstChild(childName)
|
||||
if child then return child end
|
||||
while true do
|
||||
child = parent.ChildAdded:wait()
|
||||
if child.Name==childName then return child end
|
||||
end
|
||||
end
|
||||
|
||||
function newSound(id)
|
||||
local sound = Instance.new("Sound")
|
||||
sound.SoundId = id
|
||||
sound.archivable = false
|
||||
sound.Parent = script.Parent.Head
|
||||
return sound
|
||||
end
|
||||
|
||||
-- declarations
|
||||
|
||||
local sDied = newSound("rbxasset://sounds/uuhhh.wav")
|
||||
local sFallingDown = newSound("rbxasset://sounds/splat.wav")
|
||||
local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
|
||||
local sGettingUp = newSound("rbxasset://sounds/hit.wav")
|
||||
local sJumping = newSound("rbxasset://sounds/button.wav")
|
||||
local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
|
||||
sRunning.Looped = true
|
||||
|
||||
local Figure = script.Parent
|
||||
local Head = waitForChild(Figure, "Head")
|
||||
local Humanoid = waitForChild(Figure, "Humanoid")
|
||||
|
||||
-- functions
|
||||
|
||||
function onDied()
|
||||
sDied:Play()
|
||||
end
|
||||
|
||||
function onState(state, sound)
|
||||
if state then
|
||||
sound:Play()
|
||||
else
|
||||
sound:Pause()
|
||||
end
|
||||
end
|
||||
|
||||
function onRunning(speed)
|
||||
if speed>0 then
|
||||
sRunning:Play()
|
||||
else
|
||||
sRunning:Pause()
|
||||
end
|
||||
end
|
||||
|
||||
-- connect up
|
||||
|
||||
Humanoid.Died:connect(onDied)
|
||||
Humanoid.Running:connect(onRunning)
|
||||
Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
|
||||
Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
|
||||
Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
|
||||
Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
|
||||
</string>
|
||||
<bool name="archivable">true</bool>
|
||||
</Properties>
|
||||
</Item>
|
||||
</roblox>
|
||||
Reference in New Issue
Block a user