There’s a couple red flags that I see here. Just to name a few:
- Health is NOT replicated. (The drown script for taking damage should be on the server)
- If your script is on the server already, you cannot define the player as
game.Players.LocalPlayer - The ray method used in this example code is deprecated, use the newer workspace:Raycast() with the correct RaycastParams
- Using wait() instead of task.wait()
- Doing this under a
while wait() loop
There’s some other misc stuff like how you should define the properties of an Instance before parenting it to a descendant of workspace. Why? Click here
Since you’re new to programming, none of this that I mentioned is going to be obvious to you. I pointed it out though just so you’re aware next time and can learn from this experience.