This code is for a simulator game , if player collected a gems it will show +1 Gems Gui on screen .
is there any code that can do better then this ?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteFolder = ReplicatedStorage:WaitForChild("GemsGuiRemote")
local TweenService = game:GetService("TweenService")
local Gems1 = script.Parent.Gems1
local Gems2 = script.Parent.Gems2
local Gems3 = script.Parent.Gems3
local count = script.Parent.Count
RemoteFolder.ShowLobbyGems.OnClientEvent:Connect(function()
if count.Value == 1 then
count.Value =2
local CloneGems1 = Gems1:Clone()
CloneGems1.Parent = script.Parent
local CloneGems1TweenOff = TweenService:Create(
CloneGems1,
TweenInfo.new(.1),
{
ImageTransparency = 1
}
)
local Indicator1 = TweenService:Create(
CloneGems1.Indicator,
TweenInfo.new(.1),
{
TextTransparency = 1
}
)
CloneGems1.Indicator.Visible = true
CloneGems1.Visible = true
CloneGems1:TweenPosition(
UDim2.new(0.682, 0,0.4, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
true,
2
)
wait(2)
CloneGems1TweenOff:Play()
Indicator1:Play()
wait(.1)
CloneGems1:Destroy()
elseif count.Value == 2 then
count.Value = 3
local CloneGems2 = Gems2:Clone()
CloneGems2.Parent = script.Parent
local CloneGems2TweenOff = TweenService:Create(
CloneGems2,
TweenInfo.new(.1),
{
ImageTransparency = 1
}
)
local Indicator2 = TweenService:Create(
CloneGems2.Indicator,
TweenInfo.new(.1),
{
TextTransparency = 1
}
)
CloneGems2.Indicator.Visible = true
CloneGems2.Visible = true
CloneGems2:TweenPosition(
UDim2.new(0.331, 0,0.2, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
true,
2
)
wait(2)
CloneGems2TweenOff:Play()
Indicator2:Play()
wait(.1)
CloneGems2:Destroy()
elseif count.Value == 3 then
count.Value = 1
local CloneGems3 = Gems3:Clone()
CloneGems3.Parent = script.Parent
local CloneGems3TweenOff = TweenService:Create(
CloneGems3,
TweenInfo.new(.1),
{
ImageTransparency = 1
}
)
local Indicator3 = TweenService:Create(
CloneGems3.Indicator,
TweenInfo.new(.1),
{
TextTransparency = 1
}
)
CloneGems3.Indicator.Visible = true
CloneGems3.Visible = true
CloneGems3:TweenPosition(
UDim2.new(0.377, 0,0.6, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
true,
2
)
wait(2)
CloneGems3TweenOff:Play()
Indicator3:Play()
wait(.1)
CloneGems3:Destroy()
end
end)