function onKeyDown(key)
Key = key:lower()
if key == "q" then
Move1 = game.Lighting.Fireball:Clone()
Move1.Parent = Backpack -- Would I have to change to game.Players.Backpack?
end
mouse.KeyDown:connect(onKeyDown)
Please correct it.
function onKeyDown(key)
Key = key:lower()
if key == "q" then
Move1 = game.Lighting.Fireball:Clone()
Move1.Parent = Backpack -- Would I have to change to game.Players.Backpack?
end
mouse.KeyDown:connect(onKeyDown)
Please correct it.
First off; you're definitely missing an end in that function, which in and of itself might be your only problem. Another reason the script isn't working might be that your Backpack and mouse aren't defined. To do so, use;
Player = game.Players.LocalPlayer --Assuming this is a LocalScript
mouse = Player:GetMouse()
Backpack = Player.Backpack
Lastly, KeyDown is deprecated, and it would be in your best interest to use 'UserInputService'. In your example, you could use the following code;
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
Backpack = Player.Backpack
serv = game:GetService("UserInputService")
serv.InputBegan(function(input) -- triggers every time the client uses keyboard/whatever is available
if input.UserInputType == Enum.UserInputType.Keyboard and --Checks if client has a keyboard
input.UserInputState == Enum.UserInputState.Begin then -- Self-explanatory
if input.KeyCode == Enum.Keycode.Q then -- In keydown, this'd be 'if key == "q" then'
Move1 = game.Lighting.Fireball:Clone()
Move1.Parent = Backpack
end
end
end)
Thanks so much I will use this one.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Is BackPack already defined?
What do you mean?