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

How do i make a variable for the player who damages the NPC with a tool??

Asked by 6 years ago

When a player equips a tool, the tool get's transferred to the player's character in workspace. So i thought this would work:

humanoid.Parent.Head.Touched:connect(function(otherpart)
if otherpart.Name == "Handle" then
    local character = otherpart.Parent.Parent
local player = character:GetPlayerFromCharacter(character)
print(character.Name)

I basically have a sword as a tool in the backpack. Otherpart.Parent.Parent would be the player's character, since the tool got transferred inside the player's character in workspace.

Why does Roblox Studio give this error?

GetPlayerFromCharacter is not a valid member of Model

1 answer

Log in to vote
0
Answered by
tek_o 56
6 years ago

You used a function that you never created ...(character)

0
I see what u mean now. Thanks kattenverzorger 23 — 6y
Ad

Answer this question