How Could I Make it so when it kicks the bag, the bag tweens and it gives +1 to the players leaderstats.Strength?
The hitPart is for when the player hits the wall, the boxhitpart is for when the player hits the punching bag
the hitpart works but not the boxhitpart.
local function hitPart(hit)
if Zone1Parts:FindFirstChild(hit.Name) then
local hum = hit:FindFirstChild("Humanoid")
hum:TakeDamage(10 + Player.leaderstats.Strength.Value)
local tweenInfo = TweenInfo.new(
0.1, -- Time
Enum.EasingStyle.Bounce, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local goal = {}
local function rand()
local rand = math.random(0,1)
return rand
end
goal.CFrame = hit.CFrame*CFrame.new(rand(),0,rand())
local tween = TweenService:Create(hit, tweenInfo, goal)
tween:Play()
print(hum.Health)
print(hum.Parent)
if hum.Health == 0 or hum.Health < 0 then
hum.Parent:Destroy()
--hum.Parent.Transparency = 1
--hum.Parent.CanCollide = false
--hum.Parent.CanTouch = false
end
end
end
local function boxhitpart(hit)
if Zone1PunchingArea:FindFirstChild(hit.Name) then
local hum = hit:FindFirstChild("Humanoid")
hum:TakeDamage(0)
Player.leaderstats.Strength.Value += 1
local tweenInfo = TweenInfo.new(
0.1, -- Time
Enum.EasingStyle.Bounce, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local goal = {}
local function rand()
local rand = math.random(0,1)
return rand
end
goal.CFrame = hit.CFrame*CFrame.new(rand(),0,rand())
local tween = TweenService:Create(hit, tweenInfo, goal)
tween:Play()
print(hum.Health)
print(hum.Parent)
end
end
