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

Attempt to index local "mouse" (a nil value) Anyone have any ideas?

Help someone. Filtering is enabled and I've tried to pass on the mouse from the local script but it just isn't working. Anyone have any ideas because I'm desperate.

-- Local Script

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()


anim = game.ReplicatedStorage.Caught

script.Parent.Equipped:connect(function()
	mouse.Button1Down:connect(function()
				
	script.Parent.RemoteEvent:FireServer(mouse,anim)
	end)
end)

-- Script

script.Parent.RemoteEvent.OnServerEvent:connect(function(Player,mouse,anim)
	if mouse.Target ~= nil then
		local Hit = mouse.Target
			if Hit.Name == ("Torso") or Hit.Name == ("Head") or Hit.Name == ("Left Leg") or Hit.Name == ("Right Leg") or Hit.Name == ("HumanoidRootPart") or Hit.Name == ("Left Arm") or Hit.Name == ("Right Arm") then
				local Jailed = Hit.Parent
				local Jailed2 = Jailed.Torso
				local Jailed1 = Player.Character.Torso
				local attachmentB = Instance.new("Attachment",Jailed2)
				local attachmentA = Instance.new("Attachment",Jailed1)
				attachmentA.CFrame = CFrame.new(1,-0.7,0.3)
				attachmentB.CFrame = CFrame.new(0,0,0.3)
			
				local ropeConstraint = Instance.new("RopeConstraint",Jailed1)
				ropeConstraint.Attachment0 = attachmentA
				ropeConstraint.Attachment1 = attachmentB
				ropeConstraint.Length = 10
				ropeConstraint.Visible = true
				ropeConstraint.Color = BrickColor.Black()
				ropeConstraint.Thickness = 0.2
				ropeConstraint.Restitution = 0.5
				local caught = Jailed.Humanoid:LoadAnimation(anim)
				caught:Play()
	
				script.Parent.Unequipped:connect(function() 
					ropeConstraint:Destroy()
					caught:Stop()
				end)
	end end	
end)

5 comments

0

On the player variable add, or game.Players.PlayerAdded:Wait()

0

Plus connect is depricated, use Connect

0

does not matter.

0

I fixed it anyway, thank you

1 answer

Here's the thing, you cannot send the mouse over as an argument to be read by the server, you will have to send individual stuff over, so if you want to get the mouse.Target over you will have to send that over instead of the entire mouse.

FireServer(mouse.Target,anim)

script.Parent.RemoteEvent.OnServerEvent:connect(function(Player,target,anim)

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