Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a ray that goes from the torso down, and if it hits "Grass" then it prints?

Asked by 6 years ago
Edited 6 years ago

Here's the script that I've gotten together, for some reason it wont work. It's a local script:

    local Player = game.Players.LocalPlayer
while true do
    wait(.1)
    local torso = Player.Character.Torso
    local ray = Ray.new(torso.Position, Vector3.new(0, -10, 0) * 500)
    local part, endPoint = workspace:FindPartOnRay(ray)

    if part.Name == ("Grass") then
        print("GRASS")
    end
end

basically I'm trying to make a ray from the torso, go down from the torso, detect if it hits a block. If the "block" name is "Grass" then print("GRASS"). Thank you for your help.

1
Why not just use the touched event? User#5423 17 — 6y
0
Imagine you have an RPG game and you want to reduce lag, if he uses a lot of parts for a quest system, it can cause lag saSlol2436 716 — 6y

Answer this question