Tweening Tree Grouped

local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
local Replicatedstorage = game:GetService("ReplicatedStorage")
local Woodadd = Replicatedstorage.Wood
local woodPosition = UDim2.new(0.253, 0,-0.028, 0)
local tweenInfo = TweenInfo.new(2)
local leaderstats = Players.LocalPlayer:WaitForChild("leaderstats")
local wood = leaderstats.Wood
rotation = CFrame.Angles(0,0, math.rad(75))
local damage = 20
local canSwing = true
db = true

handle.Touched:Connect(function(hit)
	if hit.Parent.Name == "Tree"and db == true  and not canSwing then
		local amount

		if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that

		else
			amount = Instance.new("IntValue")
			amount.Parent = goi
		end
		
		amount = goi:FindFirstChildOfClass("IntValue")
		
		local tree = hit.Parent
		local modelCFrame = tree:GetPivot()
		local health = tree.Health
		local DamageDelt = tree.DamageDelt
		db = false
		
		goi.CanvasGroup.Visible = true
		health.Value -= damage
		DamageDelt.Value += damage
		amount.Value += 1
		
		if health.Value == 0 or health.Value < 0 then
			print(health.Value)
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			wood2.Parent = Players.LocalPlayer.PlayerGui.Items
			wood2.Position = UDim2.new(xnew,0,0.76,0)
			wood2.TextLabel.Text = "+1"
			local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
			tween:Play()
			
			local function TreeFalls(tree, angle : number) -- should be the tree model
				local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
				local tween = Tween:Create(tree.PrimaryPart, tween_info, {
					CFrame = tree.PrimaryPart * CFrame.angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
				})
				tween:Play()
			end

			goi.CanvasGroup.Visible = false
			goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
			amount:Destroy()
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end
		
		if health.Value <= 100 then
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			wood2.Parent = Players.LocalPlayer.PlayerGui.Items
			wood2.Position = UDim2.new(xnew,0,0.76,0)
			wood2.TextLabel.Text = "+1"
			local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
			tween:Play()
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end

		
		task.wait(1)
		db = true

	else
		print(hit.Parent.Name)
	end	
end)

handle.Parent.Activated:Connect(function()
	if canSwing then
		canSwing = false

		task.wait(1)

		canSwing = true
	end
end)

Did you call the function? remember to pass the arguments

whoopsps :::::::::::::::::::::::::::::::::

Uh you are supposed to put it outside the connected function, and whenever you want the tween to play on the tree, you call it.

This was an example

local goal = {CFrame = CFrame.angles(0,0,math.rad(75))}

I also wasn’t in studio to test it, also you should of fixed it yourself. Well anyways, replace that with this

local goal = {CFrame = script.Parent.CFrame * (CFrame.new(0,-3,0) * CFrame.Angles(0,0,math.rad(75)))}

Sorry for the delayed response, had some problems when testing

it is saying invalid argument #1 to ‘rad’ (number expected, got nil)

Did you pass an angle to the function? It’s the second argument.

wdym? Sorry im new to coding

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Use this line to call the tween:

TreeFalls(wood2, 75)

Remember the first argument (wood2) must be a model, and you also need to set a Primary Part.

it says attempt to call a nil value still on the CFrame line

Can you show me your script?

4duhweoidhowndliwjepd

local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
local Replicatedstorage = game:GetService("ReplicatedStorage")
local Woodadd = Replicatedstorage.Wood
local woodPosition = UDim2.new(0.253, 0,-0.028, 0)
local tweenInfo = TweenInfo.new(2)
local leaderstats = Players.LocalPlayer:WaitForChild("leaderstats")
local wood = leaderstats.Wood
rotation = CFrame.Angles(0,0, math.rad(75))
local damage = 20
local canSwing = true
db = true

handle.Touched:Connect(function(hit)
	if hit.Parent.Name == "Tree"and db == true  and not canSwing then
		local amount

		if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that

		else
			amount = Instance.new("IntValue")
			amount.Parent = goi
		end
		
		amount = goi:FindFirstChildOfClass("IntValue")
		
		local tree = hit.Parent
		local modelCFrame = tree:GetPivot()
		local health = tree.Health
		local DamageDelt = tree.DamageDelt
		db = false
		
		goi.CanvasGroup.Visible = true
		health.Value -= damage
		DamageDelt.Value += damage
		amount.Value += 1
		
		local function TreeFalls(tree, angle : number) -- should be the tree model
			local TS = game:GetService("TweenService")
			local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
			local tween = TS:Create(tree, tween_info, {
				CFrame = tree * CFrame.angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
			})
			tween:Play()
		end
		
		if health.Value == 0 or health.Value < 0 then
			print(health.Value)
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			wood2.Parent = Players.LocalPlayer.PlayerGui.Items
			wood2.Position = UDim2.new(xnew,0,0.76,0)
			wood2.TextLabel.Text = "+1"
			local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
			tween:Play()
			TreeFalls(wood2, 75)
			goi.CanvasGroup.Visible = false
			goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
			amount:Destroy()
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end
		
		if health.Value <= 100 then
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			wood2.Parent = Players.LocalPlayer.PlayerGui.Items
			wood2.Position = UDim2.new(xnew,0,0.76,0)
			wood2.TextLabel.Text = "+1"
			local tween = Tween:Create(wood2, tweenInfo, {Position = woodPosition})
			tween:Play()
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end

		
		task.wait(1)
		db = true

	else
		print(hit.Parent.Name)
	end	
end)

handle.Parent.Activated:Connect(function()
	if canSwing then
		canSwing = false

		task.wait(1)

		canSwing = true
	end
end)

wrong one

Give this script a try:

local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
local Replicatedstorage = game:GetService("ReplicatedStorage")
local Woodadd = Replicatedstorage.Wood
local woodPosition = UDim2.new(0.253, 0,-0.028, 0)
local tweenInfo = TweenInfo.new(2)
local leaderstats = Players.LocalPlayer:WaitForChild("leaderstats")
local wood = leaderstats.Wood
rotation = CFrame.Angles(0,0, math.rad(75))
local damage = 20
local canSwing = true
db = true


local function TreeFalls(tree, angle : number) -- should be the tree model
	local TS = game:GetService("TweenService")
	local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
	local tween = TS:Create(tree, tween_info, {
		CFrame = tree * CFrame.angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
	})
	tween:Play()
end

handle.Touched:Connect(function(hit)
	if hit.Parent.Name == "Tree"and db == true  and not canSwing then
		local amount

		if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that

		else
			amount = Instance.new("IntValue")
			amount.Parent = goi
		end
		
		amount = goi:FindFirstChildOfClass("IntValue")
		
		local tree = hit.Parent
		local modelCFrame = tree:GetPivot()
		local health = tree.Health
		local DamageDelt = tree.DamageDelt
		db = false

		
		goi.CanvasGroup.Visible = true
		health.Value -= damage
		DamageDelt.Value += damage
		amount.Value += 1
		
		if health.Value == 0 or health.Value < 0 then
			print(health.Value)
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			TreeFalls(tree, 75)
			goi.CanvasGroup.Visible = false
			goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
			amount:Destroy()
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end
		
		if health.Value <= 100 then
			goi.CanvasGroup.Amount.Size = UDim2.new(DamageDelt.Value/100,0,0,75)
			local random = math.random(1,90)
			local xnew = random/100
			local wood2 = game.ReplicatedStorage.Wood:Clone()
			TreeFalls(tree, 75)
			task.wait(1.3)
			wood.Value += 1
			wood2:Destroy()
		end

		
		task.wait(1)
		db = true

	else
		print(hit.Parent.Name)
	end	
end)

handle.Parent.Activated:Connect(function()
	if canSwing then
		canSwing = false

		task.wait(1)

		canSwing = true
	end
end)

Also the next time you get an error, PLEASE tell me the line number, ty!

It says attempt to call nil valye line 21

Replace CFrame.angles with CFrame.Angles the capitalization might be important.

Now it is saying invalid argument #1 (CFrame expected, got Instance) on the same line

Can you show me the function?

asbduhewodihwoe

local function TreeFalls(tree, angle : number) -- should be the tree model
	local TS = game:GetService("TweenService")
	local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
	local tween = TS:Create(tree, tween_info, {
		CFrame = tree * CFrame.Angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
	})
	tween:Play()
end

mb :skull: It should have been tree.PrimaryPart.CFrame, please replace it.

local function TreeFalls(tree, angle : number) -- should be the tree model
	local TS = game:GetService("TweenService")
	local tween_info = TweenInfo.new(2, Enum.EasingStyle.Bounce)
	local tween = TS:Create(tree.PrimaryPart, tween_info, {
		CFrame = tree.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(angle)) + Vector3.new(0,-3,0)
	})
	tween:Play()
end

soo wood2 is a ui thing I made and idk what is supposed to be there.

TreeFalls(wood2, 75)