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

How do you bring a value with a RemoteEvent?

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

✓ Accepted answer

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

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