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

Why does this part stay in the air and does not move?

This is my script:

	local laser = Instance.new("Part", game.Workspace)
	laser.FormFactor = "Custom"
	laser.Size = Vector3.new(0.2, 0.2, 2.6)
	laser.CanCollide = false
	laser.Anchored = false
	laser.CFrame = CFrame.new(fireFromPart.Position, cPos)
	
	local prop = Instance.new("BodyVelocity")
	prop.Parent = laser
	prop.velocity = (cPos - handle.Position).Unit * velocity

I made a tool that shoots laser beam type things when you cleck the left button. Before I made this part of the script I just cloned the beam from serverstorage but that caused lag problems so I made it so it makes the beam inside the script. Now when I click the shoot button the beam shows up where it is supposed to show up, everything is right except the beam does not move. can anyone find a problem here?

If I change the part position or size when it's already shot it starts moving

4 comments

0

Is it anchored?

0

It's obviously not anchored. Although not a real solution, you already have the bullet pointing in the correct direction. Now you can just use lookVector to make it fly straight. prop.velocity = laser.CFrame.lookVector * velocity

0

Is the beam sticking to your tool or any parts? I think it might be welding itself to something when it's parented to the workspace.

0

There are no weld scripts in the tool or workspace.

1 answer

✓ Accepted answer

It's either because where you place you laser instance or because you don't set velocity maxForce. TOOL is not defined here

local laser = Instance.new("Part", workspace);
local mouse = player:GetMouse();

laser.FormFactor = "Custom";
laser.Size = Vector3.new(2.6,2.6,2.6);
laser.TopSurface = "Smooth";
laser.BottomSurface = "Smooth";
laser.CanCollide = false;
laser.CFrame = TOOL.Handle.CFrame;
laser.CFrame = CFrame.new(laser.Position, mouse.Hit.p);

local laserVelocity = Instance.new("BodyVelocity", laser);
laserVelocity.velocity = laser.CFrame.lookVector * 90;
laserVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge);

2 comments

0

Fixed the problem by setting the CFrame before setting the size and other properties. Still thanks for the help!

0

No problem!

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