While I was coding a magic script, I got an error message that says "19:18:12.082 - ServerScriptService.SuperpowersScript:36: attempt to index local 'Mouse' (a nil value)" but I already defined Mouse
local RS = game:GetService("ReplicatedStorage")
local RemotesFolder = RS:WaitForChild("Remotes")
local DeathBomb = RemotesFolder:FindFirstChild("DeathBomb")
local EffectsFolder = RS:FindFirstChild("Effects")
local BallEffect = EffectsFolder:FindFirstChild("Ball")
local SpikeyEffect = EffectsFolder:FindFirstChild("Spikey")
DeathBomb.OnServerEvent:Connect(function(player)
local Character = player.Character
local Mouse = player:GetMouse()
local Ball1 = BallEffect:Clone()
local Spikey1 = SpikeyEffect:Clone()
wait()
Ball1.Parent = player.Character
Ball1.Anchored = true
Ball1.BrickColor = BrickColor.new("Royal purple")
Ball1.Material = Enum.Material.Neon
Ball1.CanCollide = false
Ball1.Locked = true
Ball1.Size = Vector3.new(1,1,1)
Ball1.Position = Character:WaitForChild("RightHand").Position + Vector3.new(0,.5,0)
Spikey1.BrickColor = BrickColor.new("Royal purple")
Spikey1.Anchored = true
Spikey1.CanCollide = false
Spikey1.Parent = player.Character
Spikey1.Position = Ball1.Position
Spikey1.Transparency = .75
for i = 1,20 do
Ball1.Size = Ball1.Size + Vector3.new(.05,.05,.05)
Spikey1.Orientation = Spikey1.Orientation + Vector3.new(1,1,1)
wait()
end
local BoomBoom = Ball1:Clone()
local BV = Instance.new("BodyVelocity", BoomBoom)
BV.Velocity = Mouse.Hit.LookVector * 100
Ball1:Destroy()
end)

1 comment
Because the player's mouse doesnt replicate to the server