So i have a script that does dmg when you punch someone, and i would like to set their “In Combat” boolean to true after they get hit. The problem is i can’t just do
Since if i get multiple times, it wouldn’t stop from setting it to false on the first attack, instead i want it to reset to 30seconds each time you get hit.
--Initializing variables
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(30)
local tween
--Code that would go in your punch method
local InCombat = target:FindFirstChild("InCombat")
InCombat.Value = true
if tween == nil then
tween = TweenService:Create(InCombat, tweenInfo, {Value=false})
else
tween:Cancel()
end
tween:Play()
[/quote]
You can also use the tween.Completed event and add extra handling if you need it for whether the tween was “Completed” or it was “Cancelled”