#Tween not tweening
1 messages · Page 1 of 1 (latest)
client-side code:
local coolDown = false
local coolDownTime = 0.6
local animID = script.Animation
local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChildOfClass("Animator")
local track = animator:LoadAnimation(animID)
local treeHit = game.ReplicatedStorage:FindFirstChild("treeHit")
local function swingAxe()
if coolDown then return end
coolDown = true
local handle = tool:FindFirstChild("Handle")
if not handle then
coolDown = false
return
end
local size = handle.Size + Vector3.new(3, 2, 2)
local cf = handle.CFrame * CFrame.new(-1, 0, 0)
local parts = workspace:GetPartBoundsInBox(cf, size)
track:Play()
for i, part in ipairs(parts) do
if part.Name == "Tree" then
treeHit:FireServer(part.Parent)
print("axe touched part ")
end
end
task.delay(coolDownTime, function()
coolDown = false
end)
end
tool.Activated:Connect(swingAxe)
server-side code:
local tweenService = game:GetService("TweenService")
treeHit.OnServerEvent:Connect(function(player, treeModel)
if not treeModel or not treeModel:IsA("Model") then return end
local primary = treeModel.PrimaryPart
if not primary then return end
local info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true)
local goal = {CFrame = primary.CFrame * CFrame.new(0, 2, 0)}
local tween = tweenService:Create(primary, info, goal)
tween:Play()
end)```
(I sented the wrong vid 💀 )