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

3 comments
If you're using a script then that's the problem, you can only use it in local scripts
@TheNINJA152 If I Click on a player will it take damage on it?
No. You have to use remote events.