while true do wait(.25) ray = Ray.new(Char.Head.Position,Vector3.new(0,1,0).unit*5000) part = workspace:FindPartOnRayWithWhitelist(ray,whitelist,false) AudioData = script:WaitForChild("AudioData") if part ~= nil then ray2 = Ray.new(part.Position,Vector3.new(0,1,0).unit*5000) advpart = workspace:FindPartOnRayWithWhitelist(ray2,whitelist2,false)
The problem seems to lie in the ray variable. When the player dies and respawns, it stops updating the player's head's position. I need to figure out how to get it to continue updating so the script continues to cooperate. Probably an easy fix, but I'm still in new territory for myself.
Never mind, I fixed it. "Char" was defined as "workspace.WaitForChild(Plr.Name)", which for a reason I have yet to fully understand was causing the issue. I changed it to the following:
ray = Ray.new(Plr.Character.Head.Position,Vector3.new(0,1,0).unit*5000)
This seemed to fix the problem completely. If anyone wants to help me understand what was going on with these two, I'd love to understand why my trial and error fixed it.