-- part of script
local function _defaultDamageCallback(system, target, amount, damageType, dealer, hitInfo, damageData)
if target:IsA("Humanoid") then
local objetivo = game.Players:GetPlayerFromCharacter(target.Parent).Team
local atacante = dealer.Team
if objetivo ~= atacante or game.Players:GetPlayerFromCharacter(target.Parent).Neutral == true or dealer.Neutral == true then
target:TakeDamage(amount)
end
local objetivo1 = game.Players:GetPlayerFromCharacter(target.Parent)
local atacante1 = dealer
game.ReplicatedStorage.kill:FireServer(objetivo, atacante, objetivo1, atacante1) -- this isn't works
end
end
-- server script
game.ReplicatedStorage.kill.OnServerEvent:Connect(function(objetivo, atacante, objetivo1, atacante1)
print("objetivo")
print("atacante")
print("objetivo1")
print("atacante1")
end)
I’m pretty sure you can’t just do :TakeDamage to deal damage to people (I might be wrong). Btw, if it is a local script, you can’t deal damage and have it replicate to the server.
One of the problems you are going to run into is that OnServerEvent automatically takes the client who calls it as the first argument, and you will need to catch your variables based on this.
Example:
--Server
.OnClientEvent:Connect(function(plr, firstArg)
print(firstArg) -- this will print 'This is my actual variable'
end)
--Client
:FireServer('This is my actual variable')
Let me know if this solves your problem before I look at the code more in-depth. There is nothing wrong with the way you are calling FireServer at face value.
You missed with calling of function.
Just put in your local script, after function:
_defaultDamageCallback(),
or else, if you need to make function on damage, just put:
for example:
script.Parent.Humanoid.HealthChanged:Connect(_defaultDamageCallback)
Because if function dont be called, all code in current function dont be completing.
Maybe, this is problem to fall calling of RemoteEvent.
How is the FireServer() not working? (Also, the first variable in the FireServer() event is the player, so you may want to account for that.)
Also, is the first part in a LocalScript or in a ServerScript because you cannot fire remotevents from the server, you can only listen to them; unless you use :FireAllClients() or use :FireClient().
If I can suggest anything further, it’s to see if there are any errors popping up; that and manually fire the event to see if the script isn’t able to fire the actual event. That; and perhaps see if the name of the RemoteEvent isn’t “kill”; and that it is actually a class of “RemoteEvent” because if it is not, you cannot use :FireServer().