generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Rays

Previous Thread :: Next Thread 
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 10:37 AM
I want to raycast to the ground, 20 studs above the player, and the ray should always go to a random direction, instead of straight down to the player.
How do I accomplish this "spread", anyone able to help me out here?


game.Players.LocalPlayer.CharacterAdded:wait()
local char = game.Players.LocalPlayer.Character


while true do
wait(1)
local pos = char.Torso.Position + Vector3.new(0, 20, 0)
--raycast
end
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 12:42 PM
bump
Report Abuse
SmoothBlockModel is not online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
10 Feb 2013 12:49 PM
while true do
wait(1)
local pos = char.Torso.Position
local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50),-1000,math.random(-50,50))
local part,endpoint = Workspace:FindPartOnRay(ray)
end

Haven't tested. Edit the -50,50 for more/less radius of randomness.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 02:20 PM
You left out one parenthesis, but it doesn't work, tried to use it like this:

while true do
wait(1)
for i = 1, 5 do
local pos = char.Torso.Position
local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50)),-1000,math.random(-50,50))
local hit,position = Workspace:FindPartOnRay(ray)
if hit then
if hit.ClassName == "Part" then
if hit.Material == "Grass" then
--draw shrubbery
local m = Instance.new("Part", workspace)
m.Position = position
m.Anchored = true
m.CanCollide = false
end
end
end
end
end
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 04:54 PM
bump...
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 07:13 PM
bump......
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
10 Feb 2013 07:52 PM
bump, need help
Report Abuse
SmoothBlockModel is not online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
10 Feb 2013 08:25 PM
while true do
wait(1)
for i = 1, 5 do
local pos = char.Torso.Position
local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50),-1000,math.random(-50,50)))
local hit,position = Workspace:FindPartOnRay(ray)
if hit then
if hit.ClassName == "Part" and hit.Material == "Grass" then
--draw shrubbery
local m = Instance.new("Part", Workspace)
m.Position = Vector3.new(position)
m.Anchored = true
m.CanCollide = false
end
end
end
end

Try this
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image