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)```
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.
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)```