Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Can I Share Variables With Remote Events?

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

✓ Accepted answer

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)

2 comments

0

ooh .. thanks !! You helped me a lot

0

Now: Afte 8 months i realized how exploitable my remote was :D

This discussion is preserved as it was. New answers, comments, and votes are closed.