Can anyone help me with this Value Lose limb script?

Can anyone here help me determine why this script doesn’t work? The object is to have a value for every time you take more than 1 piece of candy you lose a limb. If you take 2 pieces of candy, you will lose your left arm. However, if you take 3, you will lose both limbs then die.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	local value = plr:FindFirstChild("NumV")
	
	local CandClone = Candy:Clone()
	CandClone.Parent = plr:WaitForChild("Backpack")
	
	local limb1 = plr:FindFirstChild("Left Arm")
	
	local limb2 = plr:FindFirstChild("Right Arm")
	
	if value then
		
		if value.Value == 0 then
			value.Value = 1
			
			
		elseif value.Value == 1 then
			value.Value = 2
			limb1:Destroy()
	
			
		elseif value.Value >= 2 then
			value.Value = 3
			
			limb2:Destroy()
			
			
			wait(.5)
			
			plr.Parent:FindFirstChild("Humanoid").Health = 0
			value.Value = 0
		end
		print("He has a value")
	end
end)```
1 Like

The players limbs aren’t stored in Player, they are in the Player’s Character Model. I think you would need to do plr.Character:FindFirstChild(“Left Arm”).

EDIT: Also, if your game is R15, you would need to delete, RightUpperArm, RightLowerArm, And RightHand.

1 Like

Ah alright, dang I forgot! Thanks bro. I’ll see if that works.

Unfortunately, this isn’t working. I don’t know why.

local Candy = game.ServerStorage:WaitForChild("Candy")


script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	local value = plr:FindFirstChild("NumV")
	
	local CandClone = Candy:Clone()
	CandClone.Parent = plr:WaitForChild("Backpack")
	
	local char = plr.Character
	
	local limb1 = char:WaitForChild("Left Arm")
	
	local limb2 = char:WaitForChild("Right Arm")
	
	if value and limb1 and limb2 then
		
		if value.Value == 0 then
			value.Value = 1
			
			
		elseif value.Value == 1 then
			value.Value = 2
			limb1:Destroy()
	
			
		elseif value.Value == 2 then
			value.Value = 3
			
			limb2:Destroy()
			
			
			wait(.5)
			
			plr.Parent:FindFirstChild("Humanoid").Health = 0
			value.Value = 0
		end
		print("He has a value")
	end
end)```

You need to wrap a ClickDetect in a function and call it I think. For Example

 local clickDetector = script.Parent
 local function onClicked(player)
    -- Your Coding Stuff
 end

clickDetector.MouseClick:Connect(onClicked)

Another problem I found is this.

plr.Parent:FindFirstChild("Humanoid").Health = 0
		value.Value = 0

You need to do plr.Character.Humanoid.Health = 0 since Humanoid is also a child of the Player’s Character.

Hope this helps.

1 Like