Colors are automatically put on the ghost to reflect the player's color.
Also, if a thok trail is what the outcome is supposed to be, the code would be:
addHook("PlayerThink", function(player)
if not(player.mo and player.mo.valid and player.mo.skin == "skinname") then return end
if...