Make snowflakes

I am trying to make a snowflake appear inside of a frame that covers the entire screen. So far I have this part which should make them spawn in. [They are image labels.] In the output I keep getting this error. Any ideas?

Error:
image

Code:

function makesnow()
	
	local snow = script.Snow
	local newsnow = snow:Clone()
	newsnow.Parent = script.Parent
	newsnow.ImageTransparency = 0
	newsnow.Position.X.Offset = math.random(1,900)
	newsnow.Position.Y.Offset = .1

	end

while true do
	wait(.1)
	makesnow()
end
3 Likes

You have to set the position to a new UDim2 because the UDim2 values are read-only

newsnow.Position = UDim2.fromOffset(math.random(1, 900), 0.1)

Also, the offset is in pixels, so you might wanna make it a whole number instead of 0.1

3 Likes

One last thing about UDim2, How would I make the thing go slowly down?

2 Likes

you could use tweening.

or a loop that slowly lowers it by subtracting a value off the offset, but from personal experience I would just recommend tweening it.

2 Likes

How would I do that? I havent used tweening before.

3 Likes
GuiObject:TweenPosition()

Here is the API

it is a pretty hard process to remember, I forget it alot to.
here is the fundamentals, well to tween most things, but there is one specifically made for GUI that @veraxAltruism already stated.

game:GetService("TweenService"):Create(INSTANCE, TweenInfo.new(EASINGTIME, EASINGSTYLE, EASINGDIRECTION, 0,false,0), {GOAL}):Play()

2 Likes

This is the code, It keep saying “Unable to cast from dictionary”

game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0,false,0), {900}):Play()

alright so your issue is your not defining what you want to change. In the goal area, (I probably should have been more specific, sorry) You need to have a statement, e.g

game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0,false,0), {Position = EXAMPLE THING}):Play()

also your placing a number, in short your telling the computer here is the number now figure out what to do with it. You need to give it what you want to change with the number

What would I set the example to? I just want it to move down.

game:GetService("TweenService"):Create(newsnow, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0,false,0), {Position = UDim2.new(0, newsnow.Position.X.Offset, 0, -3000)}):Play()

try that. Not 100% sure if it would work

3 Likes
game:GetService("TweenService"):Create(newsnow, TweenInfo.new(8, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0,false,0), {Position = UDim2.new(0, newsnow.Position.X.Offset, 0, 3000)}):Play()

This brings them to the bottom left.

1 Like

Got it to work. Thanks for the help.

1 Like

No problem, just tell me if you need anything more

3 Likes