Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"attempt to index local 'mouse' (a nil value)"?

Hi. A local script inside a tool fires a RemoteEvent also placed inside the tool when activated with the arguments of:

firere:FireServer(mouse, hum, handle, damage, flyoffvals)

The script that runs when RemoteEvent is fired looks like this:

local firere = script.Parent:WaitForChild("Fire")

firere.OnServerEvent:connect(function(player, mouse, hum, handle, damage, flyoffvals)
	
	local fb = handle:Clone()
	fb.Parent = game.Workspace
	fb.Name = "Fireball"
	fb.CFrame = handle.CFrame
	
	print(player.Name .. "'s fireball was launched!")
	
	local particle = fb:WaitForChild("ParticleEmitter")
	
	particle.LockedToPart = false
	particle.Rate = 300
	
	local bv = Instance.new("BodyVelocity", fb)
	bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bv.Velocity = mouse.Hit.lookVector * 350
	
	print(player.Name .. "'s fireball BodyVelocity was created!")
	
	game.Debris:AddItem(fb, 1.5)
	
	fb.Touched:connect(function(part)
		local vhum = part.Parent:findFirstChild("Humanoid")
		if vhum and vhum.Health > 0 and vhum ~= hum then
			vhum:TakeDamage(damage)
			
			for x = 1,10 do
				local cfb = fb:Clone()
				cfb.Parent = game.Workspace
				cfb.Position = fb.Position
				cfb.BodyVelocity.Velocity = Vector3.new(flyoffvals[math.random(1, #flyoffvals)], flyoffvals[math.random(1, #flyoffvals)], flyoffvals[math.random(1, #flyoffvals)])
				game.Debris:AddItem(cfb, 1.5)
			end
			
			fb:Destroy()
			
		elseif part.Anchored == true and part.CanCollide == true then
			for x = 1,10 do
				local cfb = fb:Clone()
				cfb.CFrame = fb.CFrame
				cfb.BodyVelocity.Velocity = Vector3.new(flyoffvals[math.random(1, #flyoffvals)], flyoffvals[math.random(1, #flyoffvals)], flyoffvals[math.random(1, #flyoffvals)])
				game.Debris:AddItem(cfb, 1.5)
			end
			
			fb:Destroy()
		end
	end)
end)

I'm getting the error at line 19. I'm getting the player's mouse using "player:GetMouse()" inside the local script. All help is appreciated very, very much. Thanks :} ~Loughdough

5 comments

0

I don't see local mouse=game.Players.LocalPlayer:GetMouse() at the top of this script

0

@DanzLua I said it was in the local script...?

0

@LoughDough its not in a localscript?

1

That isn't the local script. Actually READ what I said. Someone already answered the question anyways so it doesn't matter.

0

@LoughDough don't be rude to someone who's trying to help you

1 answer

✓ Accepted answer

To the server mouse does not exist. Try just sending the lookVector instead of the mouse.

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.