So, the :FireServer()function has thing where the 1st argument is automaticlly set to the localplayer. So pretty much if you're doing.
remote:FireServer(1235, true)
remote.OnServerEvent:Connect(function(number, bool)
print(number)
print(bool)
end)
Now this should technaclly print 1235 and true, because those are the values that we fired from the local script, but no actually, it will print the player's name, and then 1235. And that's because the 1st argument is always the player, even if you didn't set it to the player. The :FireServer() will set it as the 1st argument, and let's say if you got another argument that you see as the first one, it will be second, and all arguments will be moved by one. That's what happened wiht the script that I wrote. the number paramater was the player cuz that's always first, but number which was the 1st paramater became second. And that's exactly the problem with your script. You set dmg which is a number value as a first argument, and i'm assuming that the object is the player. since as we said player is always the first argument by default. dmg became the player instance, and the number value stored as dmg became the object argument.
So this should be your script.
script.Parent.DamageEvent.OnServerEvent:Connect(function(player,dmg)
local human = player.Parent:FindFirstChild("Humanoid")
local gib = script.Gib:Clone()
gib.FX.Enabled = true
gib.CFrame = CFrame.new(player.CFrame.X,player.CFrame.Y,player.CFrame.Z)
game.Debris:AddItem(gib,0.35)
if human~=nil then
human:TakeDamage(dmg)
end
end)
And don't forget to change the arguments in the local script. The player is set to first, and the damage is second.
6 comments
The other script which is firing the server: script.Parent.DamageEvent:FireServer(dmg,target)
Roblox adds the player that fired the remote as the first argument so damage will be the player and object will hold the damage. Just add an additional parameter in the function to hold the player object.
Can you show that with a script?
our goal is not to just fix your script, it's to explain what happend too. my answer will explain as good as kingdom did and will give you an answer
soo, it worked?
you seriously didnt check back yet....