How I can stop the change with another script or insdie the same script? (more info inside)

I wanna make this local script to return the normal gravity (196.2)
If I touch part the named (EndOfAllDropper) or till I die/reset
Its local script inside StarterCharacterScripts

parent = workspace.NormalLobby.TryTheObbyTeleport.ChangingAnimationAndStart.Part


function onTouch(hit)
	--parent.Touched:connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		workspace.Gravity /= 2
	end
end
parent.Touched:connect(onTouch)
local parent = workspace.NormalLobby.TryTheObbyTeleport.ChangingAnimationAndStart.Part
local OldGravity = workspace.Gravity

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

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

		Hum.Died:Connect(function()
			workspace.Gravity = OldGravity
		end)
	end
end

parent.Touched:connect(onTouch)

1 Like

Its not work for me, I tried to die from part and reset and still the same

It is in StarterCharacterScripts, meaning the script will reset once the player respawns.

Add an IntValue in ReplicatedStorage to store the default value of gravity.

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

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

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

parent.Touched:connect(onTouch)
1 Like

Somehow its put the diffrent gravity when I start playing with no touch to the part

It seems like you didn’t set the value of the IntValue, set it to the default gravity.

I did it, and its still not work, oh wait min, nvm its work I think its didn’t save the int value cuz its was with dot maybe idk why

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