Hello, I encountered such a problem but I don’t know how to fix it. I spent a lot of time and didn’t find a solution either on the forum or on YouTube or in Google. Any help is appreciated. I don’t know how to fix it. Help!
local Debris = game:GetService("Debris")
local repStorage = game:GetService("ReplicatedStorage")
local TakeDamage = repStorage.FireTakeDamage
local function newPart(name, parent, nidPoint, start, ray, pos, color)
local part = Instance.new("Part", parent)
part.Anchored = true
part.CanCollide = false
part.Name = name
if pos then
part.CFrame = pos
part.Transparency = 1
else
part.CFrame = CFrame.new(nidPoint, start)
part.Size = Vector3.new(1,1, ray.Direction.Magnitude)
part.Transparency = 0.5
part.Material = Enum.Material.SmoothPlastic
part.Color = color
end
return part
end
local function newBeam(parent, start, endPart, curve)
local att0 = Instance.new("Attachment", start)
local att1 = Instance.new("Attachment", endPart)
local beam = Instance.new("Beam", parent)
beam.Attachment0 = att0
beam.Attachment1 = att1
beam.CurveSize0 = curve
return beam
end
local function soulHarvest(player, ray, hit)
local char = player.Character
local rayEnd = ray.Origin + ray.Direction
local rayStart = ray.Origin
if hit then
local hitChar
if hit.Parent:IsA("Accessory") then
hitChar = hit.Parent.Parent
else
hitChar = hit.Parent
end
if hitChar and hitChar:FindFirstChild("Humanoid") then
local endPart = newPart("end", game.Workspace, rayEnd / 2, rayStart, ray, hitChar.Head.CFrame, Color3.fromRGB(255, 255, 255))
local startPart = newPart("start", game.Workspace, rayEnd / 2, rayStart, ray, char.Head.CFrame, Color3.fromRGB(255, 255, 255))
local beam1 = newBeam(game.Workspace, startPart, endPart, 3)
local beam2 = newBeam(game.Workspace, startPart, endPart, -3)
hitChar.Humanoid:TakeDamage(player.Psp.Value)
Debris:AddItem(endPart, 1)
Debris:AddItem(startPart, 1)
Debris:AddItem(beam1, 1)
Debris:AddItem(beam2, 1)
end
end
end
repStorage.SoulHarvest.OnServerEvent:Connect(soulHarvest)