Is it possible to make the gravity change for only one player specifically and everyone else stays the same gravity? If it can how can it be done?
Changing the gravity in a Localscript will mean that it’ll only happen for that player.
game.Workspace.Gravity = 50
1 Like
You can do this to a player via a local script, which renders changes only for the player
local newgravity = 100
local originalgravity = 196.2
wait(2)
workspace.Gravity = newgravity
1 Like
You can use a VectorForce to apply an upward force to simulate low gravity. This is how gravity coil scripts are typically made.
local function applyLowGravity(player)
-- make sure the rootpart exists
local rootPart = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
if not rootPart then
return
end
-- create an attachment for VectorForce to be applied
local attachment = rootPart:FindFirstChild("AntiGravityAttachment")
if not attachment then
attachment = Instance.new("Attachment")
attachment.Name = "AntiGravityAttachment"
attachment.Parent = rootPart
end
-- create a force that will be used to counteract gravity
-- attach force to the attachment, and make sure it is relative to the world
-- instead of the character
local antiGravityForce = rootPart:FindFirstChild("AntiGravityForce")
if not antiGravityForce then
antiGravityForce = Instance.new("VectorForce")
antiGravityForce.Name = "AntiGravityForce"
antiGravityForce.Attachment0 = attachment
antiGravityForce.RelativeTo = Enum.ActuatorRelativeTo.World
antiGravityForce.Parent = rootPart
end
-- calculate the force the character experiences from gravity
-- force = mass * gravity
local forceOnCharacter = rootPart.AssemblyMass * workspace.Gravity
-- the percent of gravity we want the player to experience
-- 0.2 = 20% gravity. make sure this value is between [0, 1]
local gravityPercent = 0.2
-- calculate the counteracting force on the character
-- if we want the character to experience 20% gravity, we will counteract 80%
-- of the force of gravity
local antiGravityMagnitude = (1 - gravityPercent) * forceOnCharacter
antiGravityForce.Force = Vector3.new(0, antiGravityMagnitude, 0)
end
local function disableLowGravity(player)
local rootPart = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
if not rootPart then
return
end
-- cleanup the instances we made for the anti gravity force
local attachment = rootPart:FindFirstChild("AntiGravityAttachment")
if attachment then
attachment:Destroy()
end
local antiGravityForce = rootPart:FindFirstChild("AntiGravityForce")
if antiGravityForce then
antiGravityForce:Destroy()
end
end
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.