I want to make a part that damage you when you look at It, so I am deciding to use WorldToViewportPoint In order to make It, however the problem Is that I am new to It, can anyone help me?
local LocalPlayer = game:GetService("Players").LocalPlayer local PartYouWantToLook = workspace.Part local Debounce = false local function isPointVisible(Part) local camera = workspace.CurrentCamera local WorldPoint = Part.Position local vector, onScreen = camera:WorldToViewportPoint(WorldPoint) if onScreen then local origin = camera.CFrame.Position local ray = Ray.new(origin, WorldPoint - origin) local Params = RaycastParams.new() Params.FilterDescendantsInstances = {Part,LocalPlayer.Character} local Hit = workspace:Raycast(ray.Origin,ray.Direction,Params) if Hit then return false end else return false end return true end while task.wait() do if isPointVisible(PartYouWantToLook) and not Debounce then Debounce = true LocalPlayer.Character.Humanoid:TakeDamage(20) task.wait(1) Debounce = false end end