How to make the player invisible?

hello everyone, so here is my problem, i want to make the player invisible for a little while and allow a little time before he can go invisible again

first example I made:

local shiftKeyBinding = "ability_feet"

function OnBindingPressed(player, bindingPressed)
if bindingPressed == shiftKeyBinding and player.isVisible then
player.isVisible = false
end
end

function OnBindingReleased(player, bindingReleased)
Task.Wait(3)
if bindingReleased == shiftKeyBinding and (not player.isVisible) then
player.isVisible = true
end
end

function OnPlayerJoined(player)
player.bindingPressedEvent:Connect(OnBindingPressed)
player.bindingReleasedEvent:Connect(OnBindingReleased)
end

Game.playerJoinedEvent:Connect(OnPlayerJoined)

but I don't know how to leave a moment before being able to do it again
et deuxieme exemple que j'ai fait :

-- function to connect event handlers to ability events
function ConnectAbilityEvents_invisiiiible(ability)
-- hooks on entering each phase
ability.castEvent:Connect(OnCast_invisiiiible)
ability.executeEvent:Connect(OnExecute_invisiiiible)

end

-- functions called when entering each phase. Add your code inside
function OnCast_invisiiiible(ability)
print("OnCast " .. ability.name)

local Player = script:GetCustomProperty("player")
local playerPos = ability.owner:GetWorldPosition()
World.SpawnAsset("D0DB8103A69DCED4:buche permute",{ position=playerPos })


    Player.visibility = Visibility.FORCE_OFF

end

function OnExecute_invisiiiible(ability)
print("OnExecute " .. ability.name)

    Player.visibility = Visibility.FORCE_ON
-- if isTargetDataUpdated is set to true on ability phase, targetData can be used
local targetData = ability:GetTargetData()

end

-- reference to ability object, modify as needed
local myAbility = script.parent

-- call to connect events to ability.
-- this does not give the ability to player, that need to be handled separately depending on how ability is created in game
ConnectAbilityEvents_invisiiiible(myAbility)


its marks me its: attempt to index a nil value (global 'player')