Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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)
0
On the player variable add, or game.Players.PlayerAdded:Wait() saSlol2436 716 — 7y
0
Plus connect is depricated, use Connect saSlol2436 716 — 7y
0
does not matter. outlook1234567890 115 — 7y
0
I fixed it anyway, thank you ThePhantomG 30 — 7y

1 answer

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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)
Ad

Answer this question