New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How do I find myself in Workspace? I want to force the player to equip a tool.

Asked by 3 months ago

How am I supposed to find myself in workspace to equip this tool? My script:

local plr = game.Players.LocalPlayer local nameofplayer = plr.Character.Name game.Workspace["nameofplayer"].Humanoid:EquipTool(Backpack.ClassicSword)

You could just use plr.Character.Humanoid instead of having to find the character in Workspace. Denny9876 1358 — 3mo
@Denny9876 attempt to index global 'Backpack' (a nil value) iiDkOffical 11 — 3mo

1 answer

Log in to vote
Answered by
Azarth 2741 Moderation Voter Community Moderator
3 months ago
Edited 3 months ago

You don't need to find yourself in Workspace, you're using a LocalScript and already found yourself with your plr Variable. Put this in StarterPlayer > StarterCharacterScripts in a LocalScript.

local me = game.Players.LocalPlayer
local character = me.Character
local backpack = me:WaitForChild('Backpack')
local humanoid = character:WaitForChild("Humanoid")
local tool = backpack:FindFirstChild('ClassicSword')
if tool then 
Unable to cast value to Object iiDkOffical 11 — 3mo

Answer this question