Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

help with sound playing when looking at part?

Asked by 3 years ago

i wanted to do that when you look at a part, a sound plays (only for you) and when you stop looking at it the sound stops.

i tried scripting it, but it always keeps printing hitsky.

local camera = workspace.CurrentCamera
local TS = game:GetService("TweenService")
local Ray = Ray.new(camera.CFrame.LookVector, Vector3.new(224.101, 24240.299, -1423.5))

while wait(1) do
    local hit, position = game,workspace:FindPartOnRayWithIgnoreList(Ray, {camera})
    if hit then
        print("hitsky")
    end
end

this local script was placed in startergui

Answer this question