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

How Can I Share Variables With Remote Events?

Asked by 4 years ago
Edited 4 years ago

Okay, I'm still learning a lot so please dont be mad. So im trying to pass a variable from a local script with a remote event to a server script. Heres an example:

game.ReplicatedStorage.givemoney:FireServer(hitHumanoid) --local script

Server script:

game.ReplicatedStorage.givemoney.OnServerEvent:Connect(function(hitHumanoid)
    if    hitHumanoid.Health    <=    0    then 
                               hitHumanoid.Parent.creator.Value   =   "example.."
                end 

end)

**The problem is that the variable hit Humanoid will mark the player instead of that variable. *14:13:43.298 - Health is not a valid member of Player Does anyone know how to fix it?***

1 answer

Log in to vote
0
Answered by
karlo_tr10 1233 Moderation Voter
4 years ago

Remote event fired from client to server will have the player that fired it as the first argument, that means the player is assigned to "hitHumanoid" variable, you can fix it like this, also you should format your code:

game.ReplicatedStorage.givemoney.OnServerEvent:Connect(function(Player,hitHumanoid)
    if hitHumanoid.Health <= 0 then 
        hitHumanoid.Parent.creator.Value   =   "example.."
    end 
end)
0
ooh .. thanks !! You helped me a lot Newh0hrizonCz 58 — 4y
0
Now: Afte 8 months i realized how exploitable my remote was :D Newh0hrizonCz 58 — 3y
Ad

Answer this question