So, here I am in the #help-and-feedback:code-review category. Is this a good use of tweening parts?
local cocao = script.Parent
local startPos = script.Parent.StartingPosition
local storage = game.ServerStorage
local tweeningService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
15,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)
local startProperties = {
Size = script.Parent.StartingSize.Value,
Position = script.Parent.StartingPosition.Value
}
local tween = tweeningService:Create(cocao,tweenInfo,startProperties)
-- bools
local cocoaCollected = false
local cocoaAbleToCollect = true
local deb = false
local function collectCocoa(hit)
if not deb then
deb = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local cocoaStat = player.leaderstats:WaitForChild("Cocoa")
if cocoaStat ~= nil then
if cocoaAbleToCollect then
print("Made it to the collecting phase")
cocoaStat.Value = cocoaStat.Value + (1 * player.Gamepasses.CocoaMultiplier.Value)
cocoaCollected = true
cocoaAbleToCollect = false
script.Parent.Position = script.Parent.GrowingPosition.Value
script.Parent.Size = script.Parent.GrowingSize.Value
tween:Play()
wait(15)
cocoaCollected = false
cocoaAbleToCollect = true
deb = false
end
end
else
deb = false
end
end
end
cocao.Touched:Connect(collectCocoa)
When I first created the cocoa system (not this one) I just made it so it would fall and then the player would collect it.
Instead with this code the player will collect it from the tree and earn cocoa, and then the cocoa would start growing again, and that is where the tweening comes in.
I’m satisfied with everything, but I just want to know what you guys think of it.
- 1
- 2
- 3
- 4
- 5
0 voters
Thank you!