Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
|
| 15 Jul 2015 06:46 PM |
I tried making the zooming in and out sounds work, but when I tried it, it doesnt work. Whats wrong with the zooming in and out part?
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 sOuch = newSound("rbxasset://sounds/splat.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/swoosh.wav") local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3") local sZoomingIn = newSound("rbxasset://sounds/SWITCH3.wav") local sZoomingOut = newSound("rbxasset://sounds/SWITCH3.wav") sRunning.Looped = true
local Figure = script.Parent local Head = waitForChild(Figure, "Head") local Humanoid = waitForChild(Figure, "Humanoid")
-- functions
function onDied() sDied:Play() sOuch: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
function onZoomingIn(speed) if speed>0 then sZoomingIn:Play() else sZoomingIn:Pause() end end
function onZoomingOut(speed) if speed>0 then sZoomingOut:Play() else sZoomingOut: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) Humanoid.ZoomingIn:connect(function(state) onState(state, sZoomingIn) end) Humanoid.ZoomingOut:connect(function(state) onState(state, sZoomingOut) end) |
|
|
| Report Abuse |
|
|
Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
| |
|
redlo43
|
  |
| Joined: 16 Feb 2011 |
| Total Posts: 4722 |
|
|
| 15 Jul 2015 06:58 PM |
| Zoomingin is not an event ok!!!!!!! |
|
|
| Report Abuse |
|
|
Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
|
| 15 Jul 2015 07:01 PM |
Dont be mean, I just need help.
The other sounds work but not the specific one. |
|
|
| Report Abuse |
|
|
redlo43
|
  |
| Joined: 16 Feb 2011 |
| Total Posts: 4722 |
|
|
| 15 Jul 2015 07:04 PM |
| I'm not being mean!!!! Zoomingin and zoomingout are not events!!!!!!!!!!!!! Ok!!! |
|
|
| Report Abuse |
|
|
Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
|
| 15 Jul 2015 07:06 PM |
Then what should I change?
Just post the script below and Ill replace it with it. |
|
|
| Report Abuse |
|
|
Scyber
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 350 |
|
|
| 15 Jul 2015 07:09 PM |
| Use events WheelForward and WheelBackward. You'll need to get the player's mouse though |
|
|
| Report Abuse |
|
|
Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
| |
|
Scyber
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 350 |
|
|
| 15 Jul 2015 07:18 PM |
Put this code into a LocalScript and then put the LocalScript in StarterPlayerScripts in the StarterPlayer folder.
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse()
function newSound(id) local sound = Instance.new("Sound") sound.SoundId = id sound.Parent = script return sound end
local sZoomingIn = newSound("rbxasset://sounds/SWITCH3.wav") local sZoomingOut = newSound("rbxasset://sounds/SWITCH3.wav")
function onZoomingIn() sZoomingIn:Play() end
function onZoomingOut() sZoomingOut:Play() end
Mouse.WheelForward:connect(function(state) onZoomingIn() end) Mouse.WheelBackward:connect(function(state) onZoomingOut() end) |
|
|
| Report Abuse |
|
|
Daraked
|
  |
| Joined: 10 Jul 2015 |
| Total Posts: 461 |
|
| |
|