Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's wrong with this script?

The ball is created, and it stays in front of me. It doesn't move forward like it should. It decides to stop working after about 2 shots. Sometimes one.

Player = game.Players.LocalPlayer
Char = Player.Character
Torso = Char.Torso
Mouse = Player:GetMouse()
Attack = false
function onKeyDown(key)
	key = key:lower()
	if key == "f" and Attack ==  false then
		Attack = true
		local Ball = Instance.new("Part")
		Ball.Parent = workspace
		Ball.Shape = "Ball"
		Ball.Size = Vector3.new(5,5,5)
		Ball.BrickColor = BrickColor.new("Really red")
		Ball.Transparency = 0.4
		Ball.TopSurface = 0
		Ball.BottomSurface = 0
		Ball.CFrame = Torso.CFrame * CFrame.new(0,0.5,-4)
		local Bv = Instance.new("BodyVelocity")
		Bv.Parent = Ball
		Bv.maxForce = Vector3.new(math.huge,math.huge,math.huge)
		Bv.P = 1250 
		Bv.velocity = Torso.CFrame.lookVector * 1000
		game.Debris:AddItem(Ball,4)
		wait(3)
		Attack = false
	end
end
Mouse.KeyDown:connect(onKeyDown)

1 answer

Since you parented the part to the Workspace before you added the BodyVelocity, it isn't being picked up by the physics engine. Move Ball.Parent = workspace from line 11 to line 24 and it works.

2 comments

0

Why is that the case? It shouldn't matter at what point the BodyVelocity enters the part

0

I don't know why it is the case.

This discussion is preserved as it was. New answers, comments, and votes are closed.