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)
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 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
Unable to cast value to Object
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
You could just use plr.Character.Humanoid instead of having to find the character in Workspace.
@Denny9876 attempt to index global 'Backpack' (a nil value)