I'm trying to set this up so at a specific key-frame a ray is fired a couple of studs away from the player and if the ray intersects another player it'll damage them but the ray-cast function is telling me my identifier is a nil value
my pre-function locals are:
local animation
local player = game.Players.LocalPlayer
local drop_kick = Instance.new("Animation")
local playercore = player.Character.LowerTorso
local Rfoot = player.Character.RightFoot
drop_kick.AnimationId = ("rbxassetid://[code]") -- loads animation fine (censored the ID)
Core Script
game:GetService("UserInputService").InputBegan:connect(function(KeyInput)
if KeyInput.KeyCode == Enum.KeyCode.V then
if not enabled then
return
end
enabled = false
local thrust = Instance.new("BodyPosition",playercore)
thrust.maxForce = Vector3.new(280000, 1, 280000)
thrust.position = playercore.Position + playercore.CFrame.lookVector
animation = player.Character.Humanoid:LoadAnimation(drop_kick)
player.Character.Humanoid.WalkSpeed = 0
animation:Play()
animation.KeyframeReached:connect(function(KickActive)
local kickray = Ray.new(Rfoot.Position + Rfoot.CFrame.lookVector.unit * 15)
print("Ray fired, congrats :^)") -- fires a ray when the apex keyframe of the animation is played, this also works fine
local ignore = player
local blip, position = game.workspace:FindPartOnRay(kickray, blip, ignore)
----------------------------------------------------------------------------------
if blip.Name == "LowerTorso" then --- i get an error here "attempt to index local "blip" a nil value despite identifying it on line 31
return position
else return
end
local humanoid = Rfoot.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = Rfoot.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(30)
print("WHAMMO")
end
end)
-------------------------------------------------------------------------
wait(0.4)
thrust:Destroy()
wait(3)
player.Character.Humanoid.WalkSpeed = 16
print("Cooldown") -- works fine too
wait(6)
enabled = true
print("DropKick Ready")
end
end)
I gave a good look at the ray-casting links from the wiki such as the following:
http://wiki.roblox.com/index.php?title=Making_a_ray-casting_laser_gun
http://wiki.roblox.com/index.php/Raycasting
http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartOnRay
-- The ray actually confirmed to fire in the output via the print() that I assigned, my only issue is the detecting factor is telling me the part i'm looking for is a nil value.
I'm at a loss as of how to fix this, if any of you can aid me in finding a fix for this and perhaps provide some further insight i'd be incredibly grateful :^)
