How to script a space block

I want to make a space block which if you touch it, you get like low gravity but it turn you back when you touch the other brick, and I know that body forces control this space stuff, so how would I change a player’s body force using a part with a script??

to give someone low gravity when touching a block you would do

part.Touched:Connect(function(v)
if v.Parent:FindFirstChildOfClass(‘Humanoid’) then --verifies that a player touched and not a part
workspace.Gravity = 0
end
end)

Then to put gravity back you would do the opposite

part.Touched:Connect(function(v)
if v.Parent:FindFirstChildOfClass(‘Humanoid’) then
workspace.Gravity = 196.2 --default gravity
end
end)

note: this would be from the client so it only turns off their gravity

will the player fall down though? ive tried some that make player only go up for some reason

The player will fall down when gravity is greater than 0 so all you would need to do is have it at like 50 and it will work


hmm there is a red line for some reason

i added this but it still no fixes

local part = game.Workspace.Part
part.Touched:Connect(function(v)
if v.Parent:FindFirstChildOfClass(‘Humanoid’) then --verifies that a player touched and not a part
workspace.Gravity = 0
end
end)

1 Like