You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Get touching part of a ball
-
What is the issue? So I have a dummy,All of it part cancollide are true,And I have a police who will shot dummies inside,Which use collision to detect the dummy,The collision hitbox is a ball,50 stud,it has can query false and can collide false,Its collision group is 0,same as the dummy,But when i test,Ill always return only the terrain,Even if the dummy is at the center of the ball,BLock also dont work.Raycast function is called on heartbeat
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?Yes,Ive try changing the ball to a block,But that did not work,Also another note,My script worked before,Just 20 minute ago.Even if i delete if not get ancestor… it still wont work with anything aside terrain,PS.Even straght out of gettouching table,Theres no part getting registered
local function raycast ()
for _,hit in pairs(script.Parent.Parent.Range:GetTouchingParts()) do
print(hit.Name)
if not hit:FindFirstAncestor(script.Parent.Parent.Parent) then
if reloading == false and hit.Name ~= "Terrain" then
print(hit.ClassName)
reloading = true
-- Build a "RaycastParams" object
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {script.Parent.Parent,hit.Parent}
raycastParams.IgnoreWater = true
local dir = hit.Position - script.Parent.Parent.Gun.Handle.position
-- Cast the ray
local part = script.Parent.Parent.Gun.Handle
local raycastResult = workspace:Raycast(part.Position, dir*100, raycastParams)
-- Interpret the result
if raycastResult then
if raycastResult.Instance:IsA("BasePart") then
--local X,Y,Z = CFrame.new(script.Parent.Parent.HumanoidRootPart.Position,dir):ToOrientation()
--script.Parent.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.HumanoidRootPart)*CFrame.fromOrientation(0,math.rad(Y),0)
enablelight(0.05)
if raycastResult.Instance.Parent:FindFirstChildOfClass("Humanoid") then
local hum = raycastResult.Instance.Parent:FindFirstChildOfClass("Humanoid")
hum:TakeDamage(30)
end
end
else
if hit.Parent:FindFirstChildOfClass("Humanoid") then
--local X,Y,Z = CFrame.new(script.Parent.Parent.HumanoidRootPart.Position,dir):ToOrientation()
--script.Parent.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.HumanoidRootPart)*CFrame.fromOrientation(0,math.rad(Y),0)
enablelight(0.05)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
hum:TakeDamage(30)
end
end
waitpre(1)
reloading = false
end
end
end
end