Is there a way to do more optimization you think??
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remotes = ReplicatedStorage.Remotes
local clonePartEvent = remotes.ClonePartEvent
local function onServerEvent(player: Player, hit: CFrame)
local newPart = Instance.new("Part", workspace)
local newHitBox = Instance.new("Part", newPart)
local finalPos = hit
newPart.CFrame = finalPos
newPart.Transparency = 0.3
newPart.Anchored = true
newHitBox.Shape = Enum.PartType.Ball
newHitBox.Position = newPart.Position
newHitBox.Size = Vector3.new(4, 4, 4) * 1.5
newHitBox.Transparency = 0.5
newHitBox.Anchored = true
newHitBox.CanCollide = false
newHitBox.Touched:Connect(function(hit: BasePart)
if hit.Name == "HumanoidRootPart" then
local humanoid = hit.Parent.Humanoid:: Humanoid
newHitBox.CanTouch = false
humanoid:TakeDamage(10)
end
end)
task.wait(10)
newPart:Destroy()
end
clonePartEvent.OnServerEvent:Connect(onServerEvent)