Vscript SetPlayerClass() action isn't working

Top sporing fungi

L1: Registered
Mar 12, 2022
12
1
A pretty easy function, the result is a respawn and both messages but no class changes,
problem is that it should change.
this is put on a trigger for testing
The result in console is:

working
EntSelectSpawnPoint(): No valid spawns for class #TF_Class_Name_Demoman on team 2 found, even though at least one spawn entity exists.
finish
SCRIPT PERF WARNING --- "Classchanger" ran long at 3.314371ms

The Code:
function Classchanger()
{
printl("working")
activator.SetPlayerClass(2)
activator.ForceRegenerateAndRespawn()
printl("finish")
}