Generate a script in Roblox Studio that kills me when I touch a part.
- User
Generate a script in Roblox Studio that kills me when I touch a part.
Assistant
Here's a simple Lua script for Roblox Studio that will cause the player's character to die when touching a specific part:
local killPart = script.Parent -- Assumes the script is placed inside the part that will cause death function onTouched(otherPart) local character = otherPart.Parent local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.Health = 0 -- Instantly kills the character end end killPart.Touched:Connect(onTouched)To use this script:
- In Roblox Studio, create a part you want to use as the "kill part"
- Insert a Script inside that part
- Copy and paste the above code into the script
The script will make the part instantly kill any character that touches it by setting the Humanoid's health to 0.
A few notes:
- Place the script directly inside the part you want to act as a death trigger
- This works for both players and NPCs with Humanoid components
- The character will die instantly upon touching the part
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.