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

EquipTool function?

Asked by 10 years ago

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

0
What you were doing was looking in the workspace for a part/script/etc for an object literally named 'playername' Mystdar 352 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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

0
Thanks, man. I tried that earlier but I did 'Workspace.[playername]' xD bestbudd1 45 — 10y
Ad

Answer this question