As you can see from the image below I tried to send 2 object’s to the server but ended up with just 1.
What I’m guessing is that since both have the same name the server just ignores the other one since it’s from the client the server does not believe that the other one exist.
RECIEVING
local event = script.Parent:WaitForChild("RemoteEvent")
local debounce = false
local lastCall = {}
event.OnServerEvent:Connect(function(player, data)
if not lastCall[player] then
lastCall[player] = {tick(), {0, tick()}}
else
if (math.max(tick() - lastCall[player][1], 0.001)) < 0.3 and (tick() - lastCall[player][2][2]) > 5 then
lastCall[player][2][1] += 1
lastCall[player][2][2] = tick()
warn(player.Name.." is consecutively fireing the event. "..lastCall[player][2][1])
end
lastCall[player][1] = tick()
end
print(data)
for _, v in pairs(data) do
v[1]:TakeDamage(v[2])
end
end)
SENDING
local animationId = {{9446755252, 0.3}, {9446990358, 0.3}, {9449086272, 0}}
local animation = Instance.new("Animation")
local loadedAnimation = {}
local event = script.Parent:WaitForChild("RemoteEvent")
local sword = script.Parent.Parent:WaitForChild("Katana")
local comboCount = 1
local lastSwing = tick()
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
repeat wait(1) until player.Character and player.Character.Humanoid and player.Character.HumanoidRootPart
local character = player.Character
local humanoidRootPart = character.HumanoidRootPart
local humanoid = character.Humanoid
local debounce = false
local canDamage = false
local data = {}
for i = 1, #animationId do
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://"..tostring(animationId[i][1])
table.insert(loadedAnimation, humanoid:LoadAnimation(animation))
end
function combo(count)
humanoidRootPart.CFrame = humanoidRootPart.CFrame * CFrame.new(0, 0, -1)
loadedAnimation[count]:Play()
wait(animationId[count][2])
end
mouse.Button1Down:Connect(function()
if not debounce then
debounce = true
canDamage = true
data = {}
local extraDelay = 0
if (tick() - lastSwing) > 0.7 then
comboCount = 1
else
comboCount += 1
end
if comboCount > 2 then
extraDelay = 1
end
combo(comboCount)
lastSwing = tick()
if extraDelay ~= 0 then
canDamage = false
event:FireServer(data)
wait(extraDelay)
else
canDamage = false
event:FireServer(data)
end
debounce = false
print(data)
end
end)
sword.Touched:Connect(function(hit)
if canDamage == true then
if not hit:IsDescendantOf(character) then
local eHum = hit.Parent:FindFirstChildOfClass("Humanoid")
if eHum and not data[hit.Parent] then
data[hit.Parent] = {eHum, 5}
end
end
end
end)