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 » Scripters
Home Search
 

Re: Creating a zero gravity area for players in a local area.

Previous Thread :: Next Thread 
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:13 PM
Hi, i'm creating a running game and need help with script creation. One issue i'm currently facing is how to create a zone where a player can have zero gravity when he steps into it, and normal gravity when he leaves it. Please help, this is currently one of the many things slowing down my progress on the game. I would appreciate it if you can post some script examples below so I can test them out and make them fit to the game.
-CrezzaC
Report Abuse
Baseness is not online. Baseness
Joined: 07 Oct 2015
Total Posts: 1001
31 May 2017 12:18 PM
BodyForce, GetMass(), Region?


Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:20 PM
Is this using a local player function? On touch or something?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 12:26 PM
use local scripts and change workspace.Gravity
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:41 PM
Trying it with this script, no luck. :(



script.Parent.Touched:connect(function()
wait(0.02)
workspace.gravity = 0.5
end)
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 12:42 PM
because u need to look up local scripts on the roblox wiki and it will tell u y
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 12:42 PM
"A LocalScript will only run Lua code if it is a descendant of one of the following objects:
A Player's Backpack, such as a child of a Tool
A Player's Character model
A Player's PlayerGui
A Player's PlayerScripts
The ReplicatedFirst service
Note: the parent of the LocalScript will determine which client the Lua code will be executed on."
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:47 PM
So what you're saying is, in order for the script to run, it has to have a parent of either. :Starterpack :StarterGUI :Starterplayerscripts and :startercharacterscripts.

Should I try to lay it out so it does the following. [WHEN GAME STARTS] Local script in the "Starter player scripts" will wait for an on touched signal from the zone the player enters. When the local player enters the zone, it will run this local script making that players gravity 0.5 and nobody elses. How would I be able to get this into a LUA format?
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:48 PM
Please bare with me as i'm a novice to LUA coding.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 12:49 PM
.-.

--in starter character scripts so it always regens on death
local char = script.Parent
thing.Touched:connect(function(hit)
if char:IsAncestorOf(hit) then workspace.Gravity = 0 end
end)
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 12:56 PM
By "thing" I assume you mean the zone I want the player to run into and trigger this effect on him. Also if this script regenerates on death while its 0, that will mean the character will always have no gravity correct? If so then i'll have to set it to 180.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 12:57 PM
just set it at the top of the script and every time their character regens its parented back into their character
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 01:04 PM
This is currently what I have going:
local char = script.Parent
local zone = game.workspace.part.AGO1
zone.parent.Touched:connect(function(hit)
if char:IsAncestorOf(hit) then workspace.Gravity = 0 end
end)

-- Using this, I have managed to get this working!!
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 01:38 PM
Nevermind, still having various issues, but I think i've gotten a step closer. The script runs atleast.
Report Abuse
CrezzaC is not online. CrezzaC
Joined: 20 Sep 2014
Total Posts: 16
31 May 2017 02:19 PM
local char = script.Parent
local zone = game.workspace.part.AGO1
zone.parent.Touched:connect(function(hit)
if char:IsAncestorOf(hit) then workspace.Gravity = 0 end
end)


This script works great. Only issue is, when the player walks into another part that changes its gravity, both scripts don't work. Only one can be around at a time. Care to advise on how to fix this?
Report Abuse
Baseness is not online. Baseness
Joined: 07 Oct 2015
Total Posts: 1001
31 May 2017 03:19 PM
lowGravity = false

-- player touches part

lowGravity == true

-- player touches other part

if lowGravity == true then

lowGravity = false

end


Report Abuse
DragonHorse25 is not online. DragonHorse25
Joined: 07 Dec 2014
Total Posts: 54
31 May 2017 03:48 PM
Alrighty, so for a local area setting gravity to 0 in the workspace will set it 0 EVERYWHERE in the game. So here's what you will need to do:

Get the mass of all the body parts combined in the player using part:GetMeass() for each bodypart.
Put a bodyForce into a bodyPart (torso preferably)

Now for detecting when they enter the area.
Option1- Use a canCollide=false part and use the .touched event
set the bodyForce to Vector3.new(gravity*mass,gravity*mass,gravity*mass) when inside
set force of bodyForce to Vector3.new(0,0,0) when not inside

Option2- If are is same size in all directions then use the distance the player is from the middle of the area by doing this:
distance=(player.Torso.Position-areaMiddle.Position).magnitude-AreaSize
if distance<=0 then

--Now in here set the force of the bodyForce to: Vector3.new(gravity*mass,gravity*mass,gravity*mass)
else

--In here set force of bodyForce to Vector3.new(0,0,0)

end

And now your done!
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 07:33 PM
um y use a body force
just change gravity locally
body force is stupid for something so simple
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 07:33 PM
and idk wym but u can use TouchEnded to change it back?? idk
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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