Players.DevFoll.Backpack.Wallet.Handle.Script:3: attempt to index nil with 'Name'

So the player = nil when unequipping idk why heres my script

script.Parent.Parent.Unequipped:Connect(function()

local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)

print(Player.Name)

local Frame = Player.PlayerGui:WaitForChild("GiveMoney"):WaitForChild("Frame")

print("Hey2")

Frame.Visible = false

end)

script.Parent.Parent.Equipped:Connect(function()

local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent) or game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)

print(Player.Name)

local Frame = Player.PlayerGui:WaitForChild("GiveMoney"):WaitForChild("Frame")

print("Hey")

Frame.Visible = true

end)

When it’s not equipped you should just do:

local Player = script.Parent.Parent.Parent.Parent

You can get the character via the player’s “.Character” property. I understand what you meant though, you can’t get it via an ancestor of the tool itself.

OMG I FORGOT ABOUT THIS haha(MaxChar