When i try to launch my Code:
--// Services \\--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
--// Variables \\--
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Remote = ReplicatedStorage.FireBallEvent
local Mouse = plr:GetMouse()
--// Settings \\--
local Debounce = true
local Key = 'Q'
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://128853357'
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and Debounce and Char then
Debounce = false
Remote:FireServer(Mouse.Hit)
local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
wait(1)
Debounce = true
end
end)
I Get alwas this Error:
sw.Mjanko25.Fireball:7: attempt to index local 'plr' (a nil value)
Can someone help me?

1 comment
if this is a server script, it won't get player. You cant do local plr = game.Players.LocalPlayer in a server script.