I’m making a script that switches your gravity, but it doesn’t let me move.
Here’s my script:
local humanoid = Player.Character.Humanoid
local vectorForce = Instance.new("VectorForce", Player.Character.LowerTorso)
local att = Instance.new("Attachment", Player.Character.LowerTorso)
vectorForce.Attachment0 = att
vectorForce.Force = Vector3.new(0,5000,0)
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
coroutine.wrap(function()
while task.wait(0.1) do
local Height = (0.5 * Player.Character.HumanoidRootPart.Size.Y) + humanoid.HipHeight
local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Vector3.new(0, 1, 0) * (Height + -.1))
local Hit, Point, Normal, Material = workspace:FindPartOnRay(ray, Player.Character)
if Material then
print(Material) -- enum
end
end
end)()
coroutine.wrap(function()
while task.wait(0.1) do
humanoid:ChangeState(Enum.HumanoidStateType.Running)
humanoid.Parent.RightFoot.CanCollide = true
humanoid.Parent.LeftFoot.CanCollide = true
humanoid.Parent.RightLowerLeg.CanCollide = true
humanoid.Parent.LeftLowerLeg.CanCollide = true
end
end)()
It’s not possible to just turn the character upside down because the Humanoid’s character controller just fires a ray directly down for grounding and uses physics based on the down direction instead of looking at the character’s CFrame (this makes custom characters easier I suppose).
There is a lot of code but what you’re trying to do is easy once you find out where you need to modify the code.
Find StarterPlayerScripts Edit: Maybe starter character scripts
Inside there should be a LocalScript
Paste this code inside the LocalScript:
-- By BendsSpace
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local GravityController = require(game:GetService("ReplicatedStorage"):WaitForChild("GravityController"))
local Controller = GravityController.new(Players.LocalPlayer)
local UP = Vector3.new(0, 1, 0)
local DOWN = Vector3.new(0, -1, 0)
local gravityDirection = UP
function GetGravityUp(self, oldGravityUp)
-- Return a length one vector in the direction you want gravity
return gravityDirection
end
Controller.GetGravityUp = GetGravityUp
ContextActionService:BindAction("Flip Gravity", function(action, state, input)
if not (state == Enum.UserInputState.Begin) then return end
-- Flips gravityDirection
gravityDirection *= -1
end, false, Enum.KeyCode.G)
The example code uses the G key to flip gravity. You can use whatever method you want by setting the gravityDirection variable or modifying the GetGravityUp function.
Hey! I need some help again xd… I found out that your controls get inverted when switching gravity, I have a post here. I can’t find anything else so I’d thought I asked you.