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

FindPartOnRayWithIgnoreList Not Ignoring Character?

Asked by
Donut792 216 Moderation Voter
4 years ago

alright so as the question says my :FindPartOnRayWithIgnoreList() is not ignoring the LocalPlayer's Character and the function is supposed to ignore all Descendants of given value

LocalScript:

local camera = workspace.CurrentCamera
local anim = Instance.new("Animation")
local id = 04675084449
local name = "DestPart"
anim.AnimationId = "http://www.roblox.com/Asset?ID="..id
local tool = script.Parent
local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.ChildAdded:Wait()
local deb = false
local canhit = false
local Event = game.ReplicatedStorage.Break
local ignore = {Character}

tool.Activated:Connect(function(mouse)
    if deb == false then
        deb = true
        local viewportPoint = camera.ViewportSize / 2
        local unitRay = camera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y, 0)
        local ray = Ray.new(unitRay.Origin, unitRay.Direction * 20)
        local part, position = workspace:FindPartOnRayWithIgnoreList(ray,ignore)
        local animcont = plr.Character.Humanoid:LoadAnimation(anim)
        animcont:Play()
        if part then
            print(part:GetFullName())
            if part:IsA("Part") or part:IsA("MeshPart")or part:IsA("UnionOperation") then
                if part.Name == "DestPart" then
                    if canhit == true then
                        Event:FireServer(part)
                    end
                end
            end 
        end
        deb = false
    end
end)

1 answer

Log in to vote
1
Answered by 4 years ago

Line 8 seems to be wrong; it should be CharacterAdded, not ChildAdded

0
lol my bad, thanks for pointing that out, guess ill stop using tab to finish my functions and just type them out from now on Donut792 216 — 4y
Ad

Answer this question