I’ve made plenty of tests with which i had to spawn parts around, but i’ve met with this one problem:
When not walking, i can spawn parts infront of me without issues
However, when walking, the parts are further/closer to the character.
Is there any way of avoiding this?
Also, here’s the code that spawns the hitboxes:
function Brute.Push(Player, ...)
local Character = Player.Character
local RootPart = Character.HumanoidRootPart
local TagList = {Player}
wait(0.05)
for i = 1,3,1 do
local Hitbox = PushHitbox:Clone()
Hitbox.Parent = workspace
Hitbox.CFrame = RootPart.CFrame:ToWorldSpace(PushHitboxOffset)
for _,Part in ipairs(UtilityModule.GetTouchingParts(Hitbox)) do
if not table.find(TagList,Players:GetPlayerFromCharacter(Part.Parent)) then
local Humanoid = Part.Parent:FindFirstChild("Humanoid")
if Humanoid and Humanoid.Health ~= 0 then
Humanoid.Health -= 25
TagList[#TagList+1] = Players:GetPlayerFromCharacter(Part.Parent)
end
end
end
delay(1.5,function()
Hitbox:Destroy()
end)
wait(0.05)
end
end
Also please dont mind all the wait functions scattered around, i’m replacing them soon
Instead of spawning the parts in front of the character using only the CFrame offset away from the Character’s HumanoidRootPart, you could weld the spawned parts to the HumanoidRootPart.
This happens because of the delay between the client and the server. When you move, the server only detects the movement a few moments later, meaning your character on your screen is slightly ahead of the character on the server.
I’m assuming the parts are supposed to be a hitbox for an attack. Instead of handling it on the server, you could handle the hitbox creation on the client, so the parts will immediately create relative to where you are on your screen, and then fire a remote to the server telling it you hit a target.
You could add sanity checks when the server receives the event, such as checking the distance or adding a cooldown between hits so exploiters can’t spam it. It will be exploitable, but it should greatly limit what exploiters can do with it.
I’ve added a suspicion meter, that everytime a hitbox is spawned rises by 1, and every 0.3 seconds it lowers by 1. if it reaches 10, it kicks the player!