So i am making a gun (I made 1 post about it) that when your clicking on the player It Will take damage.
heres the script:
wait(3) local mouse = game.Players.LocalPlayer:GetMouse() -- Cant get mouse local Handle = script.Parent.Handle local Gun = script.Parent local ShootSound = script.Parent.Handle.Shoot local Humanoid = game.Players.LocalPlayer.Character.Humanoid Gun.Activated:Connect(function() mouse.Button1Down:Connect(function() if mouse.target.Parent:FindFirstChild("Humanoid").Parent ~= game.Players.LocalPlayer.Name then Humanoid:TakeDamage(20) ShootSound:Play() else ShootSound:Play() end end) end)
Now The problem Is That It says it cant index nil with getmouse() Is there any way i can fix it?
thanks
/HKprogram
hm.. well... first, the code should be on a local script second, try doing some waits
--Add this on the start (replace the wait(3) with this code) wait(3) repeat wait() until game.Players repeat wait() until game.Players.LocalPlayer
and so that should work, if not, then try to use prints to see the problem