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

Click to die block not working?

Asked by 4 years ago

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)
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) DEVLogos 8 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Well its a regular script thats a child of the part aswell as the clickdetector THEGOBLINTOPLAD 0 — 4y
0
have you tried using a local script instead? xXKingCool258Xx 39 — 4y
0
Yeah THEGOBLINTOPLAD 0 — 4y
0
it's because you included local character = player.Character too xXKingCool258Xx 39 — 4y
View all comments (5 more)
0
this is what it looks like rn and its in a local script THEGOBLINTOPLAD 0 — 4y
0
oh wait I cant post code in comments THEGOBLINTOPLAD 0 — 4y
0
add my discord Randy Butternubs #7226 if you have discord THEGOBLINTOPLAD 0 — 4y
0
aight wait xXKingCool258Xx 39 — 4y
0
Your ID is nonexistent for some reason, just remove the variables and run the script, it'll work xXKingCool258Xx 39 — 4y
Ad

Answer this question