Now while I pride myself on my ability to figure out scripting problems myself, I have to accept defeat on this one.
I’m currently making a game where the setting is in space. When you go outside the gravity should be different, ( gravity value being 100) but no matter what I tried it changed the gravity sever wide for everyone.
So in short I need help making a local gravity system.
Edit: I tried local scripts but couldn’t quite figure out the code for it.
This is very generic, please be more specific of what solutions you have attempted since it may help us construct a more individual solution since we get a wider view of how you wish the system to work as well as a basis to expand ideas off.
Given the limited context, I’ll give a broad answer.
Change the Workspace.Gravity property using a Localscript, and make that change dependent of where the player is.
Some ways to do that include:
Region3’s and check the players current region.
Giant parts with .Touched signals connection.
Raycasting to check if the player is inside a building.
Article related to the above mentioned:
I suggest using Raycasting since it would be trivial to just constantly raycast upwards to defect if the player is no longer under something, but use whatever you feel fits best.
A related question (instead about changing the music in the given area, but same concept could be applied: Music in certain areas)
Changing gravity itself won’t help much since the player will still have a sense of direction (up and down), scripting a custom camera may be necessary. You could use body forces instead of changing the value of gravity.
We really need more information about what you are trying to solve. Does gravity need to be in different directions at different places (say like on a planet or near a star)? Obviously the strength needs to change depending on where the user is, but is in only on / off or in specific regions? Will it continuously change based on distance, again like on a planet?
I’ve had good experiences with LineForce objects which have a InverseSquareLaw property which allows the Roblox physics engine to handle calculating the changing force magnitude based on distance. It also allows you to calculate gravity to multiple objects.