My gravity changes to different numbers/values (bug)

I need gravity for my new dropper game but sometimes when I walk/jump in the part who give the gravity sometimes its give the wrong gravity.
I have two script to the part, one that teleport and one who do the gravity
gravity script its local script inside startercharacterscripts

robloxapp-20221025-1802549.wmv (3.3 MB)

local part = workspace.NormalLobby.TryTheObbyTeleport.ChangingAnimationAndStart.Part
workspace.Gravity = game.ReplicatedStorage.GravityNormal.Value

function onTouch(hit)
	local Hum = hit.Parent:FindFirstChild("Humanoid")

	if Hum and hit.Parent.Name == game.Players.LocalPlayer.Name then
		workspace.Gravity /=40
	end
end

part.Touched:connect(onTouch)

I don’t send the second script I don’t think its ineed.
(the link its video, I dont really know how to send video like normal here im new to roblox forum)

What do you mean by it gives the wrong gravity? Does it not give the gravity at all? or does it give different values each time you touch the brick?

look at the video I sent, I jump/walk in the part and its give gravity and the gravity still till I finish the dropper or die.

Maybe try adding a debounce, so that when you touch the part it doesn’t spam divide the gravity.
Something like this:


local part = workspace.NormalLobby.TryTheObbyTeleport.ChangingAnimationAndStart.Part
workspace.Gravity = game.ReplicatedStorage.GravityNormal.Value

local debounce = false
local timeout = 0.5

function onTouch(hit)
	local Hum = hit.Parent:FindFirstChild("Humanoid")

	if Hum and hit.Parent.Name == game.Players.LocalPlayer.Name and not debounce then
		debounce = true
		workspace.Gravity /=40
		task.wait(timeout)
		debounce = false
	end
end

part.Touched:connect(onTouch)

don’t work. I still see different between the gravity

I’m assuming you’re resetting the gravity back to its original value after the player respawns right?

yea respawn or touch the final part, but this problem started before I did this script btw, its forever problem since I started the game

When you run the game, check the explorer tab and the gravity property. Look to see if the number is always the same or if it changes

1 Like

oh you right dam, its the same gravity I think (4.9), so you got any ideas what the problem?

Yeah, so it could be some other script affecting the player. But not 100% sure. It’s a weird issue.

yea its true its weird but I think just maybe its the teleporter doing it

nevermind its beacuse I think I jump or walk in its the issue you got any ideas for me maybe there is way?

When any part of the character touches the gravity zone, the gravity is divided by 40. This will most likely cut the gravity all the way into 0. Instead, set a specific gravity on touch.

you can give example I didn’t understand the “set a specific gravity on touch.” I did part that if you touch it its will change the gravity like you saw what i said at start

workspace.Gravity = 20
-- instead of:
workspace.Gravity /= 40

well I can try it, maybe its will be the same issue and its will be slower but ok

its getting so fast after some second (dropper game), what i can do to fix it? zone?

You could try using some body movers which modify the physics of it’s parent. So in this case, the HumanoidRootPart of the player in the dropper. These are deprecated, but they still work perfectly fine. One of the body movers might be the solution. You basically just want the character to fall down at a constant speed. I can’t test which one will work the best right now, sorry!

1 Like

well thanks for trying to help, I will try to check it , but i dont have very much skills at scripting or i can say i dont have skills at all, If you find solution btw please say it cuz prob I can’t do it I have been trying to fix my all gravity for days

1 Like