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: Trying to get a part spawn relative to a player

Previous Thread :: Next Thread 
IBlockMasterI is not online. IBlockMasterI
Joined: 11 Apr 2010
Total Posts: 293
09 Aug 2014 02:07 PM
So I want it when the part spawns in, it's directly in front of the player. I have this:
The script is inside of the PlayerGui which is inside of game.Players.Player

torso = game.Workspace:FindFirstChild(script.Parent.Parent.Name).Torso
detector = game.Lighting.EarthDetector:Clone()

if script.Parent.Parent.TeamColor == game.Teams["Earth Team"].TeamColor then

detector.Parent = game.Workspace
detector:MoveTo(torso.Position+Vector3.new(0,0,-10))

if detector:GetModelCFrame().y > torso.CFrame.y + 2 then

torso.CFrame = detector.EarthDetector.CFrame
wait(2)
detector.Parent = game.Lighting

end
end


Now the issue is, when the part spawns in it spawn in always in one direction from the player, like always one one side of the player. Relative to the player's position, but not the player's angle.

For instance, if I'm looking forward, it will spawn to the left. If I'm looking left, it will spawn to the left. If I'm looking back, it will spawn to the left. It always spawns in the exact same spot relative to the player's position, so if I turn but not move the block will stay in place. Does anyone see the issue here?
Report Abuse
IBlockMasterI is not online. IBlockMasterI
Joined: 11 Apr 2010
Total Posts: 293
09 Aug 2014 02:30 PM
It worked at first, then I added the teleport statement, it didn't work at that point. When I remove the teleport part, it still fails to work. I'm assuming I messed up the MoveTo method, however I can't see how specifically..
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
09 Aug 2014 02:32 PM
use lookvector to see which way the torso is facing



director:MoveTo(torso.CFrame.p * (torso.CFrame.lookVector * 1))

not sure if i typed that out right but yeah
look up look vector
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