How can i enable and disable egomoooses gravity controller?

I’ve tried something it can turn it on but cannot turn it off, any help?

if (Controller) then
	Controller:Destroy()
	Controller = nil
end
script.Gravity.Changed:Connect(function()	
	if script.Gravity == false then
		if Controller then
			Controller:Destroy()
		end
	else
		if (Controller) then
		else
			Controller = GravityController.new(PLAYERS.LocalPlayer)
			Controller.GetGravityUp = GetGravityUp
		end
	end
end)
3 Likes

It looks like you have a conditional statement in your code that checks whether the “Controller” variable is true or not, and either sets it to “nil” or creates a new GravityController. If you need help turning off this code, you can simply comment it out by adding two dashes (“–”) at the beginning of each line. That way, the code won’t be executed when the program runs.

Alternatively, if you want to turn off this code temporarily while keeping it in your program, you can change the conditional statement to always create a new GravityController by removing the “if (Controller) then” line and the corresponding “else” block.

1 Like

fixed it myself
jdssnfjksdnfkjsnfdjksfsd

1 Like

I’m not particularly interested, but would you be so kind as to show the people who end up on this post what the solution was?

1 Like

simple I forgot to put value,

if (Controller) then
	Controller:Destroy()
	Controller = nil
end
script.Gravity.Changed:Connect(function()	
	if script.Gravity.Value == false then
		if Controller then
			Controller:Destroy()
			Controller = nil
		end
	else
		if (Controller) then
		else
			Controller = GravityController.new(PLAYERS.LocalPlayer)
			Controller.GetGravityUp = GetGravityUp
		end
	end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.