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: Need help with a line of distance.

Previous Thread :: Next Thread 
JohnElijah is not online. JohnElijah
Joined: 06 May 2009
Total Posts: 1629
04 Nov 2012 05:25 AM

Me and my friend (In RL) Have been working on this for 2 hours now but all of our solutions have failed. We are trying to remove tools when we enter a 'rest zone' and when we come out we will get our tools back.

We tried the torso position,head and model.

Man I really need help we cannot continue with the game until we get this done. (The rest zone will be destroyed by noobs without it)
____________
-JohnElijah-/Builder/Scripter/Creator
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
04 Nov 2012 05:32 AM
You could try the Touched event In the Rest Zone's floor to delete the tools.

part.Touched:connect(function(hit)
Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
c = Player.Backpack:GetChildren()
for i=1,#c do
if c[i].ClassName == "Tool" or c[i].ClassName == "Hopperbin" then
c[i]:Remove()
end
end
end
end)

And when you come out again, Touch another brick on the floor to Give the tools back from the Lighting or something.
Report Abuse
JohnElijah is not online. JohnElijah
Joined: 06 May 2009
Total Posts: 1629
04 Nov 2012 05:37 AM

Yeah but those like to break over time. Maybe I can add a regen.

Well I will see what I can do.


Thanks!


____________
-JohnElijah-/Builder/Scripter/Creator
Report Abuse
TheGamer101 is not online. TheGamer101
Joined: 14 Feb 2009
Total Posts: 11943
04 Nov 2012 05:46 AM
You can use magnitude to see who is close to the rest area.

http://wiki.roblox.com/index.php/Magnitude

For example :

local part = game.Workspace.Part

while true do
wait(2)
local p = game.Players:GetPlayers()
for i = 1, #p do
if p[i].Character ~= nil then
local torso = p[i].Character:FindFirstChild("Torso")
if torso ~= nil then
local magnitude = (part.Position - torso.Position).magnitude
if magnitude < 20 then
----remove tools
end
end
end
end
end

Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
04 Nov 2012 05:49 AM
Yes, magnitude does the distance from point a - b for you.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
04 Nov 2012 05:50 AM
Magnitude returns the length of a vector, which in most cases is used as distance. However, it does NOT equal distance.
Report Abuse
Aerideyn is not online. Aerideyn
Joined: 16 Jan 2010
Total Posts: 1882
04 Nov 2012 06:11 AM
What do you mean? the length of a vector is the very definition of distance.
Report Abuse
TheGamer101 is not online. TheGamer101
Joined: 14 Feb 2009
Total Posts: 11943
04 Nov 2012 06:15 AM
The vector could also be a Velocity Vector(ect.), hence it would not be distance?
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
04 Nov 2012 06:31 AM
I managed to get it working using positioning. You would need to put in the deleting and cloning tools where it prints Inside and Outside Area. And since it's in a loop you would need to check to make sure the player already has the tools, Otherwise you would continously give them the same tools over and over again.

It takes positioning from a non-cancollidable part that fills the room, You could just enter the restpos and dimensions of the room manually though...
LocalScript, in StarterGui.

-- Room Dimensions:
part = game.Workspace["RestAreaPart"]
restpos = part.CFrame -- Room Centre
restxsize = part.Size.X /2 -- Distance from Centre to X Walls
restysize = part.Size.Y /2 -- Distance from Centre to Y Walls
restzsize = part.Size.Z /2 -- Distance from Centre to Z Walls

while true do

Player = game.Players.LocalPlayer
if Player.Character then
Torso = Player.Character:findFirstChild("Torso")
if Torso then
InArea = false
if Torso.CFrame.X - restpos.X < restxsize then
if Torso.CFrame.Y - restpos.Y < restysize then
if Torso.CFrame.Z - restpos.Z < restzsize then
if Torso.CFrame.X - restpos.X > -restxsize then
if Torso.CFrame.Y - restpos.Y > -restysize then
if Torso.CFrame.Z - restpos.Z > -restzsize then
InArea = true
end
end
end
end
end
end

if InArea == true then
print("Inside Area")
else
print("Outside Area")
end

end
end
wait(0.5)
end
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
04 Nov 2012 06:35 AM
Probably like the most complicated way of doing it x3
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