i believe this should work. If i understood correctly
local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
rotation = CFrame.Angles(0,0, math.rad(90))
db = true
handle.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree"and db == true then
local amount
if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that
return
else
amount = Instance.new("IntValue")
amount.Parent = goi
end
amount = goi:FindFirstChildOfClass("IntValue")
local tree = hit.Parent
db = false
local modelCFrame = tree:GetPivot()
goi.CanvasGroup.Visible = true
amount.Value += 1
if amount.Value == 1 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.20,0,0,75)
end
if amount.Value == 2 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.4,0,0,75)
end
if amount.Value == 3 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.6,0,0,75)
end
if amount.Value == 4 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.8,0,0,75)
end
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,0,0,75)
tree:PivotTo(modelCFrame * rotation)
amount:Destroy()
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
end
task.wait(1)
db = true
else
print(hit.Parent.Name)
end
end)
the value is not increasing,` i think it has to do with the first section of the code
local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
rotation = CFrame.Angles(0,0, math.rad(90))
db = true
handle.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree"and db == true then
if goi:FindFirstChild("Amout") ~= true then
local amount = Instance.new("IntValue")
amount.Parent = goi
amount.Name = "Amout"
local tree = hit.Parent
db = false
local modelCFrame = tree:GetPivot()
goi.CanvasGroup.Visible = true
amount.Value += 1
if amount.Value < 5 then -- checks if its below 5
goi.CanvasGroup.Amount.Size = UDim2.new(0.20,0,0,75)
end
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,0,0,75)
tree:PivotTo(modelCFrame * rotation)
amount:Destroy()
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
end
else
print(hit.Parent.Name)
end
end
end)
ok to give you some backstory, this script is supposed to when i click the tree and when the handle it touches it increases the value on a intvalue which makes the visual inscrease and once it does the tree fales over
handle.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree"and db == true and goi:FindFirstChildOfClass("IntValue") then
if goi:FindFirstChildOfClass("IntValue") then -- since you parent your int value to the goi thing I checked that
return
else
local amount = Instance.new("IntValue")
amount.Parent = goi
local tree = hit.Parent
local modelCFrame = tree:GetPivot()
goi.CanvasGroup.Visible = true
amount.Value += 1
if amount.Value < 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.8,0,0,75)
end
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,0,0,75)
tree:PivotTo(modelCFrame * rotation)
amount:Destroy()
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
end
db = false
task.wait(1)
db = true
end
else
print(hit.Parent.Name)
end
end)
local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
rotation = CFrame.Angles(0,0, math.rad(90))
db = true
handle.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree"and db == true 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
db = false
local modelCFrame = tree:GetPivot()
goi.CanvasGroup.Visible = true
amount.Value += 1
if amount.Value == 1 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.20,0,0,75)
end
if amount.Value == 2 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.4,0,0,75)
end
if amount.Value == 3 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.6,0,0,75)
end
if amount.Value == 4 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.8,0,0,75)
end
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,0,0,75)
tree:PivotTo(modelCFrame * rotation)
amount:Destroy()
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
end
task.wait(1)
db = true
else
print(hit.Parent.Name)
end
end)
local handle = script.Parent
local Players = game:GetService("Players")
local goi = Players.LocalPlayer.PlayerGui.Gui
local Tween = game:GetService("TweenService")
rotation = CFrame.Angles(0,0, math.rad(90))
db = true
activated = false
handle.Parent.Activated:Connect(function()
for i,hit in workspace:GetPartsInPart(handle) do
if hit.Parent.Name == "Tree"and db == true 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
db = false
local modelCFrame = tree:GetPivot()
goi.CanvasGroup.Visible = true
amount.Value += 1
print(amount.Value)
if amount.Value == 1 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.20,0,0,75)
end
if amount.Value == 2 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.4,0,0,75)
end
if amount.Value == 3 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.6,0,0,75)
end
if amount.Value == 4 then
goi.CanvasGroup.Amount.Size = UDim2.new(0.8,0,0,75)
end
if amount.Value == 5 then
goi.CanvasGroup.Amount.Size = UDim2.new(1,0,0,75)
tree:PivotTo(modelCFrame * rotation)
amount:Destroy()
goi.CanvasGroup.Visible = false
goi.CanvasGroup.Amount.Size = UDim2.new(0.2,0,0,75)
end
task.wait(1)
db = true
else
print(hit.Parent.Name)
end
end
end)