I'm currently working on a game where the player is controlled via a custom starter character. I built the rig in a way in which the player head and arms are connected by hinges. Whenever the RootWeld is destroyed by a bomb, I want to kill the player, although my script seems to not work. I'm somewhat of a noobie when it comes to scripting, so if anyone has any advice onto how to fix this easily, it would be greatly appreciated! Also, if it helps at all, I'm running this from a LocalScript in StarterCharacterScripts.
local character = script.Parent local root = character.Torso.RootWeld local neck = character.Torso.Neck repeat until true do if root == nil then character:BreakJoints() print("root destroyed") end wait() end
EDIT: The RootWeld is inside the Torso. It keeps the HumanoidRootPart attached to the player.
Try replacing the root variable with character.Torso:FindFirstChild("RootWeld")
and replace if root == nil then with if not root then. Script:
local character = script.Parent local root = character.Torso:FindFirstChild("RootWeld") local neck = character.Torso.Neck repeat until true do if not root then character:BreakJoints() print("root destroyed") end wait() end
OR
local character = script.Parent local root = character.Torso:FindFirstChild("RootWeld") local neck = character.Torso.Neck repeat until true do if root then return end character:BreakJoints() print("root destroyed") end wait() end