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

How do you bring a value with a RemoteEvent?

Asked by
iRexBot 147
6 years ago

So I'm trying to bring a value using a RemoteEvent with FE on So I was thinking "()" might be the value carry but it won't work as it prints "iRexBot"

Here is the script:

Localscript:


local Players = game:GetService('Players') local Player = Players.LocalPlayer local Storage=game:GetService('ReplicatedStorage') local Event=Storage:WaitForChild('ParticalEvent') function onClick() local num = 1 Event:FireServer(num) end script.Parent.MouseButton1Click:Connect(onClick)

Script:


local Storage = game:GetService('ReplicatedStorage') local Event = Storage:WaitForChild('ParticalEvent') --Core function onFired(num) print(num) end Event.OnServerEvent:Connect(onFired)

1 answer

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
6 years ago
Edited 6 years ago

OnServerEvent implicitly passes the player that fired it in the first place as the first argument (which is why it printed your name, iRexBot).

You can fix it by adding an extra parameter to your onFired function.

function onFired(player, num)
    print(num)
end
Ad

Answer this question