Changing gravity for only one player

Could you point out where I said “Negative gravity” in any of my messages? By reversing a force I mean many other applications other than gravity. You can have further control over your character just not for gravity using the same force. This argument is pointless so Ill move out.

This sure has a lot of replies for
game.Workspace.Gravity = 0.5

1 Like

He was trying to make a part get touched change the gravity for a single player which he didn’t clearify at first, but welp :man_shrugging:.

also workspace.Gravity = 0.5 :3

This changes the gravity for everyone, I want it to only change for the person who touched the part.

local part = workspace:WaitForChild("Part")

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if workspace.Gravity ~= 10 then 
			workspace.Gravityy = 10 -- ur gravity here
		end
	end
end)

This script^^

Put this in a LocalScript in StarterCharacterScripts:

local part = workspace:WaitForChild("Part")

part.Touched:Connect(function(hit)
	if hit:IsDescendantOf(script.Parent) then
		if workspace.Gravity ~= 10 then 
			workspace.Gravity = 10
		end
	end
end)

Working LocalScript:

local part = workspace:WaitForChild("Part")

part.Touched:Connect(function(hit)
	if (hit.Parent:FindFirstChildWhichIsA("Humanoid"))  and (hit.Parent:FindFirstChild("Humanoid") == game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"))  then
		if workspace.Gravity ~= 100 then 
			workspace.Gravity = 100-- your gravity here
		end
	end
end)
8 Likes

I’m pretty sure I told you to have this as a local script inside StarterPlayerScripts
:thinking:

It still affects everyone because it doesn’t check that the humanoid belongs to the LocalPlayer, just that it is a humanoid to begin with.

I did put it in StarterPlayerScripts as a local script.

Just curious; is this a teleport or does gravity turn off when you leave a certain area

I don’t understand your question. It changes the gravity for one player when they touch a part.

A simple way is to make an invisible block which the user touches and it changes their gravity.

debounce = true

function onTouched(hit)
local h = hit.Parent:findFirstChild(“Humanoid”)
if (h ~= nil and debounce == true) then
debounce = false
h.JumpPower = 50 //Just change this value//
wait(1)
debounce = true
end
end

script.Parent.Touched:connect(onTouched)

1 Like

That doesn’t change the gravity, it changes the JumpPower. Also we have already found a solution to the problem.

gravity blocks.rbxm (2.9 KB)

2 Likes

Oh alright, I will keep that in mind.

Alternate solution.

local part = workspace:WaitForChild("Part")

part.Touched:Connect(function(hit)
	if (hit.Parent:FindFirstChildWhichIsA("Humanoid"))  and (hit.Parent:FindFirstChild("Humanoid") == game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"))  then
		if not workspace.Gravity ~= 100 then 
			workspace.Gravity = 100-- your new gravity here
		end
	end
end)

Both of the numbers should be the same.

This post is 7 months old…

In any case, what did you change?

All I did was add a not in your script. So instead of checking if the gravity is ___ it checks if the gravity is not ___, so you can add a lot of the same script over and over again for different areas without having to add if gravity = number and if gravity = number etc. etc. .

Uh, if workspace.Gravity ~= 100 then does exactly that. It only changes the gravity if the gravity is not 100, so once it is 100, the code will never run again. On the other hand, your inclusion of not means that the code will only run if the gravity of the workspace is 100, which isn’t helpful.

By the way the ~ in ~= means not equal to, not equal to. Unless I am missing something…?

Did you find a solution on how to make gravity for one person?