Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

FindPartOnRayWithIgnoreList Not Ignoring Character?

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

✓ Accepted answer

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

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.