When i click a part then i will die but it is not work also i want to use the mouse not the clickdetector

1 Like

Any errors in the code output?

1 Like

put a local before mouse.

also do a capital c in Connect

1 Like

on line 5 do

if mouse.Target.Name == "Part" then
  • You cannot get the Humanoid from LocalPlayer.
  • It’s :Connect()
  • local Mouse = Player:GetMouse()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function()
	if Mouse.Target.Name == "Part" then
		local Humanoid = Character:FindFirstChild("Humanoid")
		if Humanoid then
			Humanoid:TakeDamage(100)
		end
	end
end)

StarterPlayer → StarterPlayerScripts

1 Like

Ok, I just want to point this out, You can get a player’s character through their player too.

He did Player:FindFirstChild("Humanoid"), Humanoid is inside of the Character, not the LocalPlayer.

Oh, sorry, yes you are right about that, I thought you meant you couldn’t get the character from the Player. lol