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

RemoteFunction to get hit and player?

How can I get both the hit and the local player?

function RemoteFunction.OnServerInvoke(hit)

Sorry I didn't explain myself correctly, I meant I need to get the local player (myself) and the hit and normally I would do:

function RemoteFunction.OnServerInvoke(player)

but since I need also:

function RemoteFunction.OnServerInvoke(hit)

I do not know how to get both of them at once.

1 answer

There is actually a function in rblx lua that does presicley what you want called GetPlayerFromCharacter()

function RemoteFunction.OnServerInvoke(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)--gets the player from the model in workspace
	end
end

for more on GetPlayerFromCharacter go to: http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerFromCharacter

1 comment

0

Oh sorry I haven't explained myself enough, edited the post, thanks for your help though!

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