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

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

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)

2 comments

0

You could just use plr.Character.Humanoid instead of having to find the character in Workspace.

0

@Denny9876 attempt to index global 'Backpack' (a nil value)

1 answer

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 
	humanoid:EquipTool(tool)
end

1 comment

0

Unable to cast value to Object

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