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

Best way to detect what’s above a part?

Asked by
Dog2puppy 168
7 years ago

So I was think about how selling stuff would work in my game, Farming Simulator. I think I’m going to go for a system where you place a trailer with grain over a part and you go inside, talk to a NPC, and the grain gets unloaded. One thing is though, I’m not sure what the best way to getting what’s above the unloading part. I was thinking something like this.

Part.Touched:connect(function(wheel)
  local Trailer = wheel.Parent
  if Trailer.Name === “Trailer” then
    local Filled = Trailer.Filled.Value
    local Grain = Trailer.Grain.Value
  else
    return
  end
end)

Part.TouchEnded:connect(function()
  local Trailer = nil
  local Filled = nil
  local Grain = nil
end)

*This is all from the top of my head. Some of it might be wrong.

This is the only way to do it that I can think of, but are there any better ways?

Answer this question