Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you pass objects in remote events?

Asked by 5 years ago

I am trying to pass an object in a remote event but when I print the object on the server it always says its nil.

Heres my code

Client

WeaponFiredEvent:FireServer(CurrentWeapon.Name, HitPart, HitPosition, HitNormal, HitMaterial, CurrentWeapon.Muzzle, BulletDistance)

Server

function OnWeaponFiredEvent(Player, WeaponName, HitPart, HitPosition, HitNormal, HitMaterial, BulletOrigin, BulletDistance)

if HitPart ~= nil then

if HitPart.Parent:FindFirstChild("Humanoid") ~= nil then

HitPart.Parent.Humanoid:TakeDamage(require(ReplicatedStorage.WeaponSettings[WeaponName]).Damage)

end

print(Player, WeaponName, HitPart, HitPosition, HitNormal, HitMaterial, BulletOrigin, BulletDistance)

for Index, Object in pairs(Players:GetChildren()) do

if Object.Name ~= Player.Name then

WeaponFiredEvent:FireClient(Object, WeaponName, HitPart, HitPosition, HitNormal, HitMaterial, BulletOrigin, BulletDistance)

end

end

end

end

It always says its nil and I am so confused.

0
Is that really all of your client code? Which would make your script send nothing and make it nil. Also your script is kind of confusing what is it that you are trying to achieve? voidofdeathfire 148 — 5y
0
No that isnt all my client code, if I put it all here it would be 200 lines and I I know that those lines arent causing the problem. And I am trying to pass an object through the remote even but every time i do it says it nil but if i print the object on the client just before firing the server its not nil so something happens GottaHaveAFunTime 218 — 5y
0
You can't 'pass' ANYTHING in remote events.. I think what you mean is Remote Functions. ReadyHappiness 109 — 5y

Answer this question