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
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);