Does any one know how to script snowballs?

Does any one know how to script snowballs?


How do I make it so when the player presses a key, for example “Ctrl”, their player does a throwing snowball animation and then they throw a round white brick simulating a snowball in front of them?
I don’t want anyone to give me a full script, just a help because I have no idea where to start, if someone can try to tell me how to make it, I’d appreciate it :grin:

3 Likes

You can use this to get the mouse

local Mouse = Player:GetMouse()

Mouse.KeyDown:Connect(function(Key)
    if Key == "Q" then -- Change this
    --- Throw a Snowball!
    end
end)

As for creating the actual snowball you will most likely want to clone a snowball and create a velocity that will launch it towards the mouse’s position.

do you know any tutorials about that velocity and launch to mouse stuff?

UserInputService is a better way

Try this: https://www.youtube.com/watch?v=NIJqp5UuILg

Okay, tysm everyone, I think I’m now ready to start scripting these snowballs

1 Like

Your best bet is to use the Roblox API.

Using video tutorials are a pain and only result in copying other peoples creations. You want to learn it so you can modify the script yourself and also use it in the future.

And I know about UserInputService @ExabyteDev but I wouldn’t recommend it to senpaiiker as they are clearly new to scripting.

I’m not new to scripting tho, I’ve already used UserInputService before, I just never made launching bricks and basically needed help to start it :blush:

I was new to this before but now I know more about launching parts. Are you looking to throw it where the mouse clicked or just straight?

The brick will launch wherever the mouse is pointing.

Sorry I thought u were new to scripting :sweat_smile:

It might be worthing using Biezer curves to give your snowballs a nice drop effect.

Heres my Biezer Curve script that I use for making archways and things:

--Minis Curve Creating Script (UnderDev)
--https://developer.roblox.com/en-us/articles/Bezier-curves
-- T is a decimal below 1, 1 means curve is completed
--So smaller intervals means more points and smoother creation
--P1 Is midpoint
--P0 and P2 are the start and finish
--Uses Pythag and current position + %Complete
--V1
function lerp(a,b,c)
	return a + (b - a) * c
end

--Lerps All the points
function CurvePoint(p0,p1,p2,t)
	t = t
	--LERP X
	Xl1 = lerp(p0.X, p1.X, t)
	Xl2 = lerp(p1.X, p2.X, t)
	XLerp = lerp(Xl1, Xl2, t)
	--LERP Y
	Yl1 = lerp(p0.Y, p1.Y, t)
	Yl2 = lerp(p1.Y, p2.Y, t)
	YLerp = lerp(Yl1, Yl2, t)
	--LERP Z
	Zl1 = lerp(p0.Z, p1.Z, t)
	Zl2 = lerp(p1.Z, p2.Z, t)
	ZLerp = lerp(Zl1, Zl2, t)
	
	Pos = Vector3.new(XLerp,YLerp,ZLerp)

	return Pos
end

-- Simplify Curve
-- T should usually be 0
function CreateCurve(p0,p1,p2,t,Inc)
	Points = {}
	t = t
	LoopCount = 0
	while t < 0.99 do
		CurvePoint(p0,p1,p2,t)	
		Points[LoopCount] = CurvePoint(p0,p1,p2,t)	
		--Keeps Track Of Progress
		LoopCount = LoopCount + 1
		t = LoopCount * Inc
	end
	return Points
end
1 Like

You can just use the velocity property on the part or if want a smooth throw like gliding threw the air use vector force.

Alright, I’ll try both your tips!! @rottendogDkR @minimic2002, I’ll try to make it like club penguin snowballs movement:
https://lh4.ggpht.com/_FQ_CYAm3SyM/Syr9sorjzfI/AAAAAAAAk90/ewNJUbTopP4/Rockhopper%20and%20Yarr%20Snowball%20Fight[5].gif?imgmax=800