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

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

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

✓ Accepted answer

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

1 comment

0

I see what u mean now. Thanks

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