Ok so, im making a defense boost tool thing, in studio it works just fine but in game it breaks.
active = false
defenseMode = false
db = false
local char = game.Workspace:WaitForChild(script.Parent.Parent.Parent.Name)
script.Parent.Activated:Connect(function()
previousHealth = char.Humanoid.Health
if active == false and defenseMode == false then
print("xd")
active = true
defenseMode = true
wait(5)
defenseMode = false
wait(30)
active = false
end
end) function onChanged()
local Diffirence = tonumber(previousHealth) - char.Humanoid.Health
if defenseMode == true then
local GetPercent = 0
local Part1 = Diffirence / 2
print(Part1)
local Part2 = Part1 / 2
print(Part2)
GetPercent = Part1 + Part2
print(GetPercent)
char.Humanoid.Health = char.Humanoid.Health + GetPercent
GetPercent = 0
end
end
char.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if db == false then
db = true
onChanged()
wait()
db = true
end
end)
