So I have a classic roblox pizza item I wanna get rid of after 3 uses, but when I try changing the value to something, it doesnt change. Can anyone tell me what im doing wrong or even maybe a better way to do it? Because its annoying me rn
enabled = true;
local value = script.Parent.Value.Value
function onActivated()
if value == 1 then
print("Use 1")
if not enabled then
return;
end
enabled = false;
Tool.GripForward = Vector3.new(.995, -.0995, -8);
Tool.GripPos = Vector3.new(-1.5, -0.9, 0.5);
Tool.GripRight = Vector3.new(-1, 0, 0);
Tool.GripUp = Vector3.new(0, 1, 0);
Tool.Handle.DrinkSound:Play();
wait(.8);
local h = Tool.Parent:FindFirstChild("Humanoid");
if (h ~= nil) then
if (h.MaxHealth > h.Health + 1.6) then
h.Health = h.Health + 7
script.Parent.Value.Value = script.Parent.Value.Value + 1
else
h.Health = h.MaxHealth
end
end
end
if value == 2 then
print("Use 2")
if not enabled then
return;
end
enabled = false;
Tool.GripForward = Vector3.new(.995, -.0995, -8);
Tool.GripPos = Vector3.new(-1.5, -0.9, 0.5);
Tool.GripRight = Vector3.new(-1, 0, 0);
Tool.GripUp = Vector3.new(0, 1, 0);
Tool.Handle.DrinkSound:Play();
wait(.8);
local h = Tool.Parent:FindFirstChild("Humanoid");
if (h ~= nil) then
if (h.MaxHealth > h.Health + 1.6) then
h.Health = h.Health + 7
value = 2
else
h.Health = h.MaxHealth
end
end
end
if value == 3 then
print("Use 3")
if not enabled then
return;
end
enabled = false;
Tool.GripForward = Vector3.new(.995, -.0995, -8);
Tool.GripPos = Vector3.new(-1.5, -0.9, 0.5);
Tool.GripRight = Vector3.new(-1, 0, 0);
Tool.GripUp = Vector3.new(0, 1, 0);
Tool.Handle.DrinkSound:Play();
wait(.8);
local h = Tool.Parent:FindFirstChild("Humanoid");
if (h ~= nil) then
if (h.MaxHealth > h.Health + 1.6) then
h.Health = h.Health + 7
value = 3
Tool:Destroy()
else
h.Health = h.MaxHealth
end
end
end
Tool.GripForward = Vector3.new(0, 0, -1);
Tool.GripPos = Vector3.new(0, 0, 0.5);
Tool.GripRight = Vector3.new(1, 0, 0);
Tool.GripUp = Vector3.new(0,1,0);
enabled = true;
end
function onEquipped()
Tool.Handle.OpenSound:play();
end
script.Parent.Activated:connect(onActivated);
script.Parent.Equipped:connect(onEquipped);```