Here is my script:
local Afk = false -- unimportant
local Player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local function Tween(Object, Properties)
TweenService:Create(Object, TweenInfo.new(0.25), Properties):Play()
end
script.Parent.MouseButton1Click:Connect(function()
Afk = not Afk -- unimportant
Player.Stats.Afk.Value = Afk -- unimportant
if Afk == true then -- unimportant
Tween(script.Parent.Parent.Ball, {BackgroundColor3 = Color3.new(0, 255, 255), Position = UDim2.new(0.8, 0, 0, 0)})
else
Tween(script.Parent.Parent.Ball, {BackgroundColor3 = Color3.new(255, 0, 0), Position = UDim2.new(0, 0, 0, 0)})
end
end)
Basically it just tweens a ball’s position from one end of a bar to the other when you click it.
This is what happens:
The first time it tweens smoothly, but after that it sort of teleports to the other side.
Your time seems to be pretty short, Also i would suggest using more than just the tween time.
Also in that case I would use UDim2.FromScale as the other numbers are pointless.
You can still clearly see that the first time it tweens and the other times it teleports, I don’t think that’s really the problem.
I suggested 2 other things did you try them? I would try anything if I was stuck, it might work it might not.
It would still work if you only give it the time, it sets all the other stuff to the defaults.
Thanks for letting me know, but this wouldn’t fix the issue, only shorten the script.
When I see that right the “Ball” you’re tweening is an image so you simply don’t have to tween the BackgroundColor rather the ImageColor.
It’s not an image, I used a uicorner instance to make the background round.
When you are tweening the color, it turns it to white for a second. that makes it seem like it is disappearing. it’s just hiding in the background.
1 Like
Edit: Nvm, thanks for the help. I decided I’ll just instantly change it from red to blue instead of tweening it.
1 Like
I know you said nvm, but I already was working on a example fix so i’ll post it anyway.
local Afk = false -- unimportant
local Player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")
local function Tween(Object, Properties)
TweenService:Create(Object, TweenInfo.new(0.25), Properties):Play()
end
script.Parent.MouseButton1Click:Connect(function()
Afk = not Afk -- unimportant
Player.Stats.Afk.Value = Afk -- unimportant
if Afk == true then -- unimportant
Tween(script.Parent.Parent.Ball, {Position = UDim2.new(0.8, 0, 0, 0)})
script.Parent.Parent.Ball.BackgroundColor3 = Color3.new(0, 255, 255)
else
Tween(script.Parent.Parent.Ball, {Position = UDim2.new(0, 0, 0, 0)})
script.Parent.Parent.Ball.BackgroundColor3 = Color3.new(255, 0, 0)
end
end)
This just sets the color, so less cool, but works.
Looks like you had the same idea lol
1 Like
The color of the gui goes white for a moment when it moves.
This is most likely due to the fact that Color3.new()
only uses numbers between 0 and 1 for each color (1 being 255 in RGB).
Try using either Color3.fromRGB()
, or Color3.new()
with numbers between 0 and 1.
2 Likes