I'm running into an issue with a lives script I recently obtained. It works perfectly whenever I'm a regular robloxian, but whenever I'm a 3D morph, It doesn't seem to work properly. 3D morphs require 5 models within the Morph: Arm1, Arm2, Leg1, Leg2 and Chest. Each one contains the parts to build the body parts within the models, and each one requires a brick called "middle" in order for them to function properly, so I'm guessing it's somthing to do with the Models within the 3D morphs.
Here's the script I'm working with to loose lives:
local db = false --Our debounce function onTouched(hit) if db == false then db = true local hitname = tostring(hit.Parent) if game.Players:findFirstChild(hitname) then local player = game.Players:findFirstChild(hitname) local lives = player:findFirstChild("Lives") lives.Value = lives.Value - 1 if lives.Value <= 0 then --If the player has lost all their lives then.. hit.Parent.Humanoid.Health = 0 --Kills the player end end wait(1) -- Wait 1 second before losing a life again when touched. db = false end end script.Parent.Touched:connect(onTouched)
local db = false --Our debounce getPlayer = function(hit) local plr for _, v in pairs(game.Players:GetChildren()) do if hit:IsDescendantOf(v.Character) then plr = v end end return plr end function onTouched(hit) if db == false then db = true local player = getPlayer(hit) if player then local lives = player:findFirstChild("Lives") lives.Value = lives.Value - 1 if lives.Value <= 0 then --If the player has lost all their lives then.. player.Character.Humanoid.Health = 0 --Kills the player end end wait(1) -- Wait 1 second before losing a life again when touched. db = false end end script.Parent.Touched:connect(onTouched)
It will check if any of the parts hit are a part of the character model and if so it will return "plr" and then it will check if plr ~= nil. Therefore if any part of their character hits it it will register and if it finds a player it will remove the life