For some reason I keep getting that exact error that Is mentioned in the title. I’m not sure what “attempt to index nil” is supposed to mean, so can anyone help me fix this error? Because I’m trying to make a raycast for a landmine.
function setUp(bombClone, user)
raycastParams.FilterDescendantsInstances = {bombHandle, user.Character}
bombClone.Anchored = false
local origin = bombClone.Position
local direction = Vector3.new(0,2,0)
local raycastResult = workspace:Raycast(origin,direction)
local raycastVisual = Instance.new("Part")
raycastVisual.BrickColor = BrickColor.new("Persimmon")
raycastVisual.Transparency = .5
raycastVisual.Anchored = true
raycastVisual.Size = Vector3.new(.5, 2, .5)
raycastVisual.Position = bombClone.Position
raycastVisual.Parent = bombClone.Parent
while task.wait() do
raycastResult = workspace:Raycast(origin, direction, raycastParams)
origin = bombClone.Position
direction = Vector3.new(0,2,0)
print(raycastResult)
if raycastResult.Instance then
if game.Players:GetPlayerFromCharacter(raycastResult.Instance.Parent) then
explode(bombClone, user)
end
end
end
end
Thanks for helping me solve my problem. Haven’t used ray casting in months because I’ve been on a bit of a hiatus so I kind of forgot a lot of things after not practicing after all of that time…
I would have most likely not make a post about this If I still had that knowledge of raycast in mind.
Also, don’t assume that everyone knows a specific thing like making a comment about someone not knowing why they got an error for something like tween service.