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

Click to die block not working?

So i'm trying to make a part that when you click on it you just flat out die. I tried asking the discord but they're like busy answering other peoples questions but even when I ask mine when all the questions are over they don't read it or just ignore it? I would consider they didn't see but idk maybe nobody on there really likes me maybe.

So I search on Google how to make a "part that kills you when you click it" and "How to get humanoid from MouseClick"

I go on the websites and type the examples in my own way but it doesn't show errors and it just doesn't work and I assume they might be outdated or something, here's what I typed:

local player = game.Players.LocalPlayer
local character = player.Character
local Part = game.Workspace.DeathPart

Part.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	playerWhoClicked.Character.Humanoid.Health = 0
	
end)

1 comment

0

Make a part, and insert a click detector, then insert a script inside the detector and write: script.Parent.MouseClick:Connect(function(Player) local Character = game.Workspace:FindFirstChild(Player.Name) if Character ~= nil and Character:IsA('Model') then Character.Humanoid.Health = 0 end end)

1 answer

If it does not work you probably:

  1. Don't have the script in the part
  2. Don't have a click detector in the part
  3. Both

To make it work do this:

Insert a part into your workspace. Then insert a click detector into that part. Now insert a script inside the click detector and type this:

script.Parent.MouseClick:Connect(function(PlayerWhoClicked)
	PlayerWhoClicked.Character.Humanoid.Health = 0
end)

(EDIT)

I tried running the script in my world, and the problem is because you included

local player = game.Players.LocalPlayer

from that error, the whole script stopped to function. You can't call anything that is outside that one particular part, that'll break the script, which what happened to yours.

9 comments

0

Well its a regular script thats a child of the part aswell as the clickdetector

0

have you tried using a local script instead?

0

Yeah

0

it's because you included local character = player.Character too

0

this is what it looks like rn and its in a local script

0

oh wait I cant post code in comments

0

add my discord Randy Butternubs #7226 if you have discord

0

aight wait

0

Your ID is nonexistent for some reason, just remove the variables and run the script, it'll work

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