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

EquipTool function?

I need help with this bit of code. I'm trying to make it to where it will equip a tool that is in someone's backpack. I need help finding the player's name and then finding the player's model that way the rest of the script can work.
This is what I have tried but in the output it says "playername is not a valid member of Workspace"

local  playername = script.Parent.Parent.Name
game.Workspace.playername.Humanoid:EquipTool(script.Parent.Parent.Backpack.STBRifle) 

btw this is in a localscript in the StarterGui

1 comment

0

What you were doing was looking in the workspace for a part/script/etc for an object literally named 'playername'

1 answer

✓ Accepted answer

game.Workspace**[playername]**.Humanoid:EquipTool(script.Parent.Parent.Backpack.STBRifle)

1 comment

0

Thanks, man. I tried that earlier but I did 'Workspace.[playername]' xD

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