So basically, my problem is that this part (a laser beam) that has a body velocity in it keeps falling down the map. It’s unanchored and has cancollide off, it has massless on tho.
(The red box is the hitbox)
The modulescript that puts a bodyvelocity in the part:
script
local functions = {}
local rs = game:GetService("ReplicatedStorage")
local event = rs.Modules.RocksEffect
local folder = rs.Modules.Rocks
local exmodule = require(rs.Modules.CustomExplosion)
local lightray = script["Light Ray Kick"]
local ts = game:GetService("TweenService")
function functions.Start(plr, humrp, beamcount)
local pos = humrp.CFrame
for i, work in pairs(workspace.Effects:GetChildren()) do
if work.Name == "Light Ray Kick" then
work:Destroy()
end
end
local lightclone = lightray:Clone()
lightclone.Parent = workspace.Effects
lightclone.CFrame = pos * CFrame.new(-1, 0, -3)
local function firelaser()
local raypart = lightclone.RayPart
local origin = raypart.Position
local direction = raypart.CFrame.LookVector * 10
local params = RaycastParams.new()
for i, filter in pairs(workspace.Effects:GetChildren()) do
if filter:IsA("BasePart") then
params.FilterDescendantsInstances = {filter}
end
end
params.FilterType = Enum.RaycastFilterType.Blacklist
local ray = Ray.new(origin, direction, params)
local raycastresult = workspace:Raycast(origin, direction, params)
if raycastresult then
warn("Raycast Resulted")
if not raycastresult.Instance:IsA("MeshPart") then
warn("Not meshpart: "..raycastresult.Instance.Name)
if raycastresult.Instance.Parent:FindFirstChildOfClass("Humanoid") then -- its either a plr or npc
warn("Has Humanoid")
local char = raycastresult.Instance.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local positionlol = Vector3.new(raycastresult.Position.X, raycastresult.Position.Y, raycastresult.Position.Z)
local new = exmodule.new("Pika Explosion")
if plr then
if not plr.Name == humrp.Parent.Name then
if game.Workspace["Player Characters"]:IsAncestorOf(char) then
new:SetParent(lightclone)
new:SetPosition(positionlol)
warn("It's a player bro")
event:FireAllClients(positionlol, 20, Vector3.new(3, 3, 3), nil, 10, false, 5)
else
new:SetParent(lightclone)
new:SetPosition(positionlol)
warn("its a player bro but its not in the folder")
event:FireAllClients(positionlol, 20, Vector3.new(3, 3, 3), nil, 10, false, 5)
end
else
warn("Same player that attacked has been detected.")
end
else
if game.Workspace["NPCs"]:IsAncestorOf(char) then
new:SetParent(lightclone)
new:SetPosition(positionlol)
warn("It's an NPC bro")
event:FireAllClients(positionlol, 20, Vector3.new(3, 3, 3), nil, 10, false, 4)
else
new:SetParent(lightclone)
new:SetPosition(positionlol)
warn("its an NPC bro but its not in the folder")
event:FireAllClients(positionlol, 20, Vector3.new(3, 3, 3), nil, 10, false, 4)
end
end
else
return print("Not a humanoid")
end
end
end
end
if beamcount == 1 then
game.Debris:AddItem(lightclone, 3)
local BodyVel = Instance.new("BodyVelocity")
BodyVel.Parent = lightclone
BodyVel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVel.Velocity = humrp.Parent["Left Leg"].CFrame.UpVector * -300
BodyVel.P = 20112412741274912
for i, effects in pairs(workspace.Effects:GetChildren()) do
if effects.Name == "Light Ray Kick" then
if effects:FindFirstChild("RayPart") ~= nil then
firelaser()
end
end
end
end
end
return functions```
I want it to not fall off the map and not get affected by gravity.