Ad
Log in to vote
0

"FindPartOnRayWithIgnoreList is not a valid member of DataModel 'Baseplate'" How do I fix this?

Asked by 6 days ago
--Variables
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

--MainScript
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)

for i,v in pairs(char:GetChildren()) do
    if v:IsA("BasePart") and v.Name ~= "Head" then
        v.LocalTransparencyModifier = v.Transparency
        v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
            v.LocalTransparencyModifier = v.Transparency
        end)
    end
end

RunService.RenderStepped:Connect(function(step)
    local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)

    local IgnoreList = char:GetChildren()

    local hit, pos = game:FindPartOnRayWithIgnoreList(ray, IgnoreList)

    if hit then
        char.Humanod.CameraOffset = Vector3.new(0,0, -(char.Head.Position - pos).magnitude)
    else
        char.Humanoid.CameraOffset = Vector3.new(0,0,-1)
    end
end)

1 answer

Log in to vote
0
Answered by 5 days ago

FindPartOnRayWithIgnoreList is a function of WorldRoot, not DataModels.

Change it to this:

local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, IgnoreList)
Ad

Answer this question