pullingRemote.OnServerEvent:Connect(function(player) -- Pulling
local character = player.Character
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local camera = game.Workspace.CurrentCamera
local rayStart = camera.CFrame.Position
local rayDirection = camera.CFrame.LookVector * 10000 -- Increasing the length of the ray for expanding the search area
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {workspace} -- Searching only within the player's character
local raycastResult = workspace:Raycast(rayStart, rayDirection, raycastParams)
if raycastResult then
local hitPart = raycastResult.Instance
print(player.Name .. " is looking at the object with the name: " .. hitPart.Name)
end
end)
So the problem is that when I look at a part and call an event, it keeps writing basePlate, even though I’m not looking at it. Why am I doing something wrong?