iceedfr
(Iceed)
February 23, 2023, 12:24am
1
Is there a way I can make the transition from Day-Night/Night-Day smooth and see it cycle through the time for like 1.5 seconds or something instead of it just instantly changing?
I tried a few things but I’m still learning how to script so they didn’t work lol.
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.Setting.Value == false then
script.Parent.Parent.Setting.Value = true
script.Parent.Parent.ImageLabel.Image = "rbxassetid://3926311105"
script.Parent.Parent.ImageLabel.ImageColor3 = Color3.new(0, 1, 0.466667)
script.Parent.Parent.ImageLabel.ImageRectOffset = Vector2.new(4, 836)
script.Parent.Parent.ImageLabel.ImageRectSize = Vector2.new(48, 48)
game.Lighting.TimeOfDay = 5.5
else
script.Parent.Parent.Setting.Value = false
script.Parent.Parent.ImageLabel.Image = "rbxassetid://3926311105"
script.Parent.Parent.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
script.Parent.Parent.ImageLabel.ImageRectOffset = Vector2.new(940, 784)
script.Parent.Parent.ImageLabel.ImageRectSize = Vector2.new(48, 48)
game.Lighting.TimeOfDay = 14.5
end
end)
TweenService is your friend here! It can be used to create animations for various properties.
In your case, you can do something like:
local TweenService = game:GetService("TweenService")
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.Setting.Value == false then
script.Parent.Parent.Setting.Value = true
script.Parent.Parent.ImageLabel.Image = "rbxassetid://3926311105"
script.Parent.Parent.ImageLabel.ImageColor3 = Color3.new(0, 1, 0.466667)
script.Parent.Parent.ImageLabel.ImageRectOffset = Vector2.new(4, 836)
script.Parent.Parent.ImageLabel.ImageRectSize = Vector2.new(48, 48)
TweenService:Create(game.Lighting, TweenInfo.New(1.5), {ClockTime = 5.5}):Play()
else
script.Parent.Parent.Setting.Value = false
script.Parent.Parent.ImageLabel.Image = "rbxassetid://3926311105"
script.Parent.Parent.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
script.Parent.Parent.ImageLabel.ImageRectOffset = Vector2.new(940, 784)
script.Parent.Parent.ImageLabel.ImageRectSize = Vector2.new(48, 48)
TweenService:Create(game.Lighting, TweenInfo.New(1.5), {ClockTime = 14.5}):Play()
end
end)
ClockTime is basically the same as TimeOfDay. If you don’t already know how to use tweens, I would suggest clicking the first hyperlink and reading about them! They can make some beautiful animations for all sorts of properties! Hope this helps!
2 Likes
iceedfr
(Iceed)
February 23, 2023, 12:44am
3
Thanks for the help!
But i’m getting an error…
Players.iceedfr.PlayerGui.Menus.Settings.Main.ScrollingFrame.Time.Button.LocalScript:10: attempt to call a nil value - Client - LocalScript:10
Oops! I made a small mistake. To fix this issue just change TweenInfo.New to TweenInfo.new! That should fix it!
1 Like
iceedfr
(Iceed)
February 23, 2023, 1:05pm
5
Alright thanks for all the help, appreciate it!
system
(system)
Closed
March 9, 2023, 1:05pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.