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

RemoteFunction to get hit and player?

Asked by
RoyMer 301 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

0
Oh sorry I haven't explained myself enough, edited the post, thanks for your help though! RoyMer 301 — 9y
Ad

Answer this question