I’m currently trying to make a script that uses a remote function to create a hitbox on the client and then send the info back to the server if it detects a player.
The issue is that for some reason it is not sending the information back to the server when it detects the player but instead it waits for the duration of the attack and just closes the hitbox without detecting anything.
This is the client script:
local function HitboxNew(Data)
local Range = Data.Range
params.FilterDescendantsInstances = {Character}
local Hit = nil
local Hum = nil
local EnemyHumanoids = {}
local hitbox = HitBoxModule.CreateHitbox()
hitbox.Size = Vector3.new(Range,Range,Range)
hitbox.CFrame = Character.HumanoidRootPart
hitbox.Offset = CFrame.new(0,0,-2.5)
hitbox.OverlapParams = params
hitbox.AutoDestroy = true
hitbox.Touched:Connect(function(hit, hum)
print("beep")
return true,hum
end)
hitbox:Start()
local Timer = 0
task.delay(.4,function()
EnemyHumanoids = nil
hitbox:Stop()
return false
end)
end
HitboxEvent.OnClientInvoke = HitboxNew
This is the server script:
coroutine.wrap(function()
if Variations[PlayerCombo.ComboVariation] == nil then
local Range = 5
local HitResult,HitObject = HitboxRemote:InvokeClient(Player, {Range = MoveData.HitboxRange or 5})
print(HitResult)
print(HitObject)
repeat
task.wait()
if HitResult then
print("Worked")
end
until HitResult or task.wait(0.4)
print("Check2")
end
end)()
If anyone could give a solution or try to explain why this is happening that it would help me out alot ty.