Yo I made something but it requires the part to be anchored, and does not use linear velocity as I find collision and gravity annoying.
local lastpos = script.Parent.Position
st=tick()
local function createBeam(posA, posB, parent)
-- Create Attachments
local attachmentA = Instance.new("Attachment")
local attachmentB = Instance.new("Attachment")
-- Set positions
attachmentA.Position = posA
attachmentB.Position = posB
-- Parent attachments to a part (or create one)
-- Parent attachments to the dummy part
attachmentA.Parent = workspace.Terrain
attachmentB.Parent = workspace.Terrain
-- Create the Beam
local beam = Instance.new("Beam")
beam.Attachment0 = attachmentA
beam.Attachment1 = attachmentB
-- Beam properties (customize as needed)
beam.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255)) -- Red beam
beam.Width0 = 5
beam.Width1 = 5
beam.Texture = "rbxassetid://16336479573"
beam.Transparency = NumberSequence.new(0,0)
beam.LightEmission = 1
beam.Parent = workspace.Terrain
beam.FaceCamera = true
game.TweenService:Create(beam,TweenInfo.new(0.5),{["Width0"]=0,["Width1"]=0}):Play()
game.Debris:AddItem(beam,0.5)
game.Debris:AddItem(attachmentA,0.5)
game.Debris:AddItem(attachmentB,0.5)
game.Debris:AddItem(part,100)
end
local function createPart(posA)
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(4,4,4)
part.Position = posA
part.Parent = workspace
end
function lethalityMetric(radius, velocity, r_max, v_max)
print(radius,velocity)
-- Normalize size and velocity
local sizeFactor = (radius^2) / (r_max^2)
local velocityFactor = velocity / v_max
-- Compute Lethality Score
local LS = sizeFactor * velocityFactor
-- Determine result
if LS >= 1 then
return LS * 100
else
local damagePercent = LS * 100 -- Interpolates from 0% to 100%
return damagePercent
end
end
--print("WORKED")
local pos = nil
local aa1 = Instance.new("Attachment")
local aa2 = Instance.new("Attachment")
aa1.Parent = script.Parent
aa2.Parent = script.Parent
local trail = Instance.new("Trail")
trail.FaceCamera = true
--trail.Lifetime = 1
--trail.Parent = script.Parent
--trail.Attachment1 = aa1
--trail.Attachment0 = aa2
--trail.LightInfluence = 0
--trail.LightEmission=1
--trail.Texture = "rbxassetid://16336479573"
--trail.TextureMode = Enum.TextureMode.Static
--trail.TextureLength = script.Parent.Size.X
--trail.Transparency = NumberSequence.new(0,0)
local Rparam = RaycastParams.new()
Rparam.FilterType = Enum.RaycastFilterType.Include
Rparam.FilterDescendantsInstances = {workspace.Map}
local list = {}
for _, v in pairs(game.Players:GetChildren()) do
if v.Character then
table.insert(list,v.Character)
end
end
table.insert(list,workspace.Map)
Rparam.FilterDescendantsInstances = list
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstAncestor("Map") and not script.Tween.Value then
print("HIT")
local raycastres = workspace:Spherecast(script.Parent.Position,script.Parent.Size.X/2,(script.Parent.Position- lastpos).Unit*1023,Rparam)
if raycastres then
script.Parent.Anchored = true
script.Parent.Position = raycastres.Position+ Vector3.new(0,0,0)
--task.wait(10)
game.ReplicatedStorage.remote.breakr:FireAllClients(20000,script.Parent,raycastres.Position,raycastres.Normal,false)
script.Parent:Destroy()
script:Destroy()
end
end
end)
while script.Parent.Parent ~= nil and tick()-st<5 do
pos = script.Parent.Position
--print("WORKING")
--workspace:sh
--print((script.Parent.Position-lastpos))
--clne.CFrame = CFrame.lookAlong(lastpos,script.Parent.AssemblyLinearVelocity)
--local spc = script.Parent:Clone()
--spc.Bullet:Destroy()
--spc.Anchored = true
--spc.CanCollide = false
--spc.CanQuery = false
--spc.CanTouch = false
--spc.Size = Vector3.new(10,10,10)
--spc.Name = "spc"
--spc.Parent = workspace
--createBeam(lastpos,lastpos+ (script.Parent.Position-lastpos))
--aa1.Position = script.Parent.AssemblyLinearVelocity.Unit*Vector3.new(1,0,1):Cross(Vector3.new(0,1,0))*5*script.Parent.Size.X/2
--aa2.Position = -script.Parent.AssemblyLinearVelocity.Unit*Vector3.new(1,0,1):Cross(Vector3.new(0,1,0))*5*script.Parent.Size.X/2
local raycastres = workspace:Spherecast(lastpos,script.Parent.Size.X/2,(script.Parent.Position-lastpos),Rparam)
createBeam(lastpos,script.Parent.Position,workspace.Terrain)
if raycastres then
--print(raycastres.Instance.Name)
local hum = raycastres.Instance.Parent:FindFirstChildOfClass("Humanoid") or raycastres.Instance.Parent.Parent:FindFirstChildOfClass("Humanoid")
if hum then
if raycastres.Instance.Name == "Head" or raycastres.Instance:FindFirstAncestor("Head") then
if lethalityMetric(script.Parent.Size.X*0.3048/2,script.Parent.AssemblyLinearVelocity.Magnitude*0.3048,0.02,1500) > 10 then
game.ServerScriptService.Events.Fight.damageDealth:Fire(script.Value.Value,hum.Health)
hum.Health =0
else
game.ServerScriptService.Events.Fight.damageDealth:Fire(script.Value.Value,lethalityMetric(script.Parent.Size.X*0.3048/2,script.Parent.AssemblyLinearVelocity.Magnitude*0.3048,0.02,1500)*2)
hum.Health = hum.Health - lethalityMetric(script.Parent.Size.X*0.3048/2,script.Parent.AssemblyLinearVelocity.Magnitude*0.3048,0.02,1500)*2
end
else
game.ServerScriptService.Events.Fight.damageDealth:Fire(script.Value.Value,lethalityMetric(script.Parent.Size.X*0.3048/2,script.Parent.AssemblyLinearVelocity.Magnitude*0.3048,0.02,1500))
hum.Health = hum.Health - lethalityMetric(script.Parent.Size.X*0.3048/2,script.Parent.AssemblyLinearVelocity.Magnitude*0.3048,0.02,1500)
end
elseif raycastres.Instance:FindFirstAncestor("Map") then
if (script.Parent.AssemblyLinearVelocity.Magnitude) then
--createPart(raycastres.Position)
--print("PENETRATW")
script.Parent.Anchored = true
script.Parent.Size = Vector3.new(10,10,10)
--script.Parent.Color = Color3.new(1,0,0)
script.Parent.Name = "BOB"
script.Parent.Position = raycastres.Position+ Vector3.new(0,10,0)
script.Parent.AssemblyLinearVelocity = Vector3.zero
--task.wait(10)
game.ReplicatedStorage.remote.breakr:FireAllClients(20000,script.Parent,raycastres.Position,raycastres.Normal,false)
script.Parent:Destroy()
break
end
end
end
lastpos = script.Parent.Position
game["Run Service"].Heartbeat:Wait()
end
bob.rbxm (8.7 KB)