✓ Accepted answer
Try this code instead
trans = script.Parent.Transparency
local function OnClicked()
for i = 1,10,1 do
trans = i/10
wait(.2)
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
or this
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local Goal = {
Transparency = 1
}
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Tween = TweenService:Create(Part, tweenInfo, Goal)
local function OnClicked()
Tween:Play()
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Using this one is more efficient since you can do more than just change the transparency.
You could also change it's BrickColor
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local Goal = {
Transparency = 1,
BrickColor = BrickColor.new("Really red")
}
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Tween = TweenService:Create(Part, tweenInfo, Goal)
local function OnClicked()
Tween:Play()
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
1 comment
it has nothing to do with in pair loops