yeah ill give the wwhole code,
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 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()
db = false
goi.CanvasGroup.Visible = true
amount.Value += 1
local goal = {Orientation = Vector3.new(0,0,75), Position = script.Parent.Position + Vector3.new(0,-3,0)}
local tweenlog = Tween:Create(tree.Tree,tweenInfo,goal)
if amount.Value == 1 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.20,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
if amount.Value == 2 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.4,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
if amount.Value == 3 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.6,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
if amount.Value == 4 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.8,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
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,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()
tweenlog:Play()
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
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)