|
Trying to play music pressing z or turn it off by pressing x
function music()
local sound = Instance.new("Sound")
sound.SoundId = "http://roblox.com/asset/?id=142533417"
sound.Parent = game.Players.LocalPlayer.PlayerGui
sound.Volume = 1
sound:Play()
wait(75)
sound:Destroy()
end
function musicstop()
if game.Players.LocalPlayer.PlayerGui:FindFirstChild("Sound") then
game.Players.LocalPlayer.PlayerGui.Sound.Volume = 0
game.Players.LocalPlayer.PlayerGui.Sound:Destroy()
else
print("No Sound")
end
end
-- end of functions
for _,plr in pairs (game.Players:GetPlayers()) do
if plr.Backpack then
local mouse = plr:GetMouse()
mouse.KeyDown:connect(function(key)
if key:lower() == "z" then
music()
elseif key:lower() == "x" then
musicstop()
end
end)
end
end |
|
|
Any day now like wtf
Bump |
|
|
Use dev console to get the output and tell us what it is. |
|
|
Why do I need the console? If it works on studio, it should work in game. And it's not. The output in studio would of told me the error |
|
|
if you don't want to check the dev console, i can't help you
it's that simple |
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
Using KeyDown requires a LocalScript. Yes, yes it does. I recommend putting a LocalScript in the startergui. Along with a repeat wait() until game.Players.LocalPlayer at the start of the code. |
|
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
I meant to say using GetMouse()
Not keydown. But, did this work? |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
@Byte
You are making it harder for yourself by being ignorant.
It seems that you are using a Script instead of a LocalScript, well there's your problem. |
|
|
I will try local script when I get home. I'm on my galaxy s4 about to have surgery and how the hell am I being ignorant? |
|
C_SharperJoin Date: 2011-10-03 Post Count: 9405 |
He's not being ignorant -_- |
|
|
Because you refused to check the dev console which would have gave us the reason of the error without having us guess possible problems. |
|
|
The studio would of given us the error and it didn't. It worked just fine. I'm going to try to put it in a local script now. |
|