I’m trying to made a beam that stops when it collides with a part, but i want it to keep going if it touches a player, I’ve tried doing,
if not Hit.Parent:FindFirstChild("Humanoid") then
print("Did not hit player")
That inside of the Touched function of course, but that does’t seem to work.
That will just ignore NPCs too.
Roblox has a function named,
Put this inside the touched function.
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- gets a player from their character
if player then -- YOU FOUND A PLAYER!
-- rest of code.
print("Did not hit player.")
return -- stops the code.
Can I do something like:
if not player then
--rest of the code
Of course, you can check if it’s not a player straight away.