I'm trying to play a sound when i look at a part. I read wikia and saw that some people recommended WorldToScreenPoint so i tried it out. As the title suggests my script didn't work and I have no idea why. It just played the sound at the start of the game and didn't work when looking at the part. I also tried RayCasting but I failed miserably. Any idea why it plays the sound at the start of the game?
Code:
local Camera = workspace.CurrentCamera
local lookpart = game.Workspace.lookpart
game.Players.PlayerAdded:Connect(function(plr)
local _, withinScreenBounds = Camera:WorldToScreenPoint(lookpart.Position)
if withinScreenBounds then
game.Workspace.Sound:Play()
print("looked")
end
end)
