Hello, i'm trying to make some kind of hitbox to use as a zone in a kind of Capture the zone game and when i touch it it works as expected but when i leave it it dont, when i touch it, it should add +1 to the "Hero" or "villain" value and when i leave it should negate -1 to it but what happen is it negate like -40 at once. (i left some notes bellow)
script.Parent.Touched:connect(function(hit)
local hero = script.Parent.Hero --this is a number value
local villain = script.Parent.Villain --^
if hit.Name == "Torso" then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local side = game.Lighting.Players:FindFirstChild(plr.Name).Side -- this is a string value
if side.Value == "Hero" then
hero.Value = hero.Value+1
elseif side.Value == "Villain" then
villain.Value = villain.Value+1
end
script.Parent.TouchEnded:connect(function()
local side = game.Lighting.Players:FindFirstChild(plr.Name).Side
if side.Value == "Hero" then
hero.Value = hero.Value-1
elseif side.Value == "Villain" then
villain.Value = villain.Value-1
end
end)
end
end
end)

1 comment
now it don't work at all for some reasons xD