So, basically I have this code that is trying to give a player a ball when "b" is pressed on their keyboard. This works in studio, but when tried in-game I get an error saying "attempt to index global 'mouse' a nil value". Any ideas?
game.Players.PlayerAdded:connect(function(player)
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
if key == "b" then
game.ReplicatedStorage.Ball:Clone().Parent = player.Backpack
end
end)
end)

1 comment
KeyDown is deprecated, you should use UserInputService or ContextActionService instead.