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

How to get default arguments along with created arguments?

For example, Epress.OnServerEvent:connect(doorModule.onEpress(canPress, Epress, Erelease)) (Epress is a remote function) How would I get the player that fired Epress while still using using my other arguments? as player is a default argument I should just be able to get it without building anything into Epress. in another script is function doorModule2.onEpress(canPress, Epress, Erelease) end

1 comment

0

Are you asking how you could get the player that fired the event?

1 answer

✓ Accepted answer

You are correct! Player is a default argument and it's always the first argument!

RemoteEvent.OnServerEvent:Connect(function(player, args)

end)

So, you can still pass through your arguments and still receive the player, like so.

Although, I'm not sure how you have and want your script set up.

--// ModuleScript
function doorModule2.onEpress(canPress, Epress, Erelease)
	RemoteEvent:FireServer(canPress, Epress, Erelease)
end

--// LocalScript
local module = require(path_to_module)

module.onEpress(true, true, true)

With that set up, you can receive the player as your first argument and the rest of your arguments that you passed through too.

--// ServerScript
RemoteEvent.OnServerEvent:Connect(function(player, canPress, Epress, Erelease)
	print(player.Name, canPress, Epress, Erelease) --// killerbrenden, true, true, true
end)

Hope this helped! If it did, feel free to mark this as an answer!

2 comments

0

thanks!

0

No problem!

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