How to get Charecter from player?

I have made this script that checks if the player has the item equipped if it does it will destroy it and clone a the equipped one but if it dosent it will erase backpack and clone equipped one but i get an error when the remote function is activated how can I fix this? I have tried changing
local hasTool = game.Workspace[player][ItemName]
to wait for child but it still dosent work

Thanks For the help!

Error— ServerScriptService.EquipItemEvent:12: bad argument #2 to ‘?’ (string expected, got Object)

local char = player.Character
	local hasTool = game.Workspace[char][ItemName]
	if hasTool then
		print("tool equipped")
		print("No Equipped tool found")


Solved i had to do local hasTool = game.Workspace[char][ItemName] and put char.Name

Player.Character already holds a reference to the model in Workspace, so you shouldn’t be doing game.Workspace[char] at all. Just use local hasTool = char[ItemName].

Also, you can use the following line of code just in case the Character hasn’t loaded yet:

local character = player.Character or player.CharacterAdded:wait()
1 Like