Works In Singleplayer/Lan but not server

I have a grave mechanic for a minigame that for some reason does not work properly on a server. Any ideas on a fix? Some parts of the code may not be relavent but im including them just in case Code found in seperate message cause character limit

Sorry this is a mess but I cant figure it out (This has been an issue for months)

Continue to help post