(Using remote events and local scripts)
I havenāt been on studio for a while but Iām sure you can just send a value you want through the remote event then In a local script youāll change the workspaceās gravity to the received value
Iām using this code:
local remoteEvent = ReplicatedStorage.ChangeGravityEvent
local function playerjoined(player)
local character = player.Character
if character then
local playerWorkspace = character.Parent
end
end
local function onGravityChange(player, gravity)
local character = player.Character
if character then
local playerWorkspace = character.Parent
playerWorkspace.Gravity = gravity
end
end
remoteEvent.OnServerEvent:Connect(onGravityChange)
Burt itās changing the gravity for all users.
Add a VectorForce into the player you want to change the āgravityā for.
The VectorForce can be set up to add to the upwards or downwards force at the center of mass if you want to decrease or increase their gravity.
This has been heavily overcomplicated. Use the following in a local script.
game.ReplicatedStorage.SetGravity.OnClientEvent:Connect(function(value)
workspace.Gravity = value
end
From a server-sided Script, use the following.
local RE = game.ReplicatedStorage.SetGravity
RE:FireClient(player, value)
I used that in a team test and it changed the gravity for all players.
Donāt use FireAllClients. Only fire the event for the player you want.
I put it in a local script that activates a function inside of the local script, which changes the gravity
local function touched(hit)
if runbefore == false then
runbefore = true
local character = hit.Parent
local player = Players.LocalPlayer
print(player)
if player then
print('yes')
local object = workspace:FindFirstChild(player.Name)
print(object)
if object then
local humanoid = object:FindFirstChild("Humanoid")
if humanoid then
changegravityGUI()
workspace.Gravity = 0
end
end
end
end
end
If the initial detection is client sided, no server communication is necessary. Just do workspace.Gravity = x in the local script.
I did do that, Iāve commented out the server side connection, SORRY I FORGOT TO ADD THE BIT WHERE I ACTUALLY CHANGE THE GRAVITY. Iām going to edit that.
In this video I had activated the gravity change and it had changed for me but it had also changed for FireFlame6910, (sorry video recording shows bad fps)
Is the touch event client side or server side? If itās server sided, only fire the remote event for the player who touched it. If itās client side, just set the gravity.
The touched() event is in a local script
You never check if the character that touched the part is the Character of the current LocalPlayer, so it enables it if any characters touch the part.
How do I get that?, Iām using the hit variableās Parent as the character.
local player = Players.LocalPlayer
local function touched(hit)
if runbefore == false then
runbefore = true
local character = hit.Parent
if character and character == player.character then
changegravityGUI()
workspace.Gravity = 0
end
end
end
Um.
So that would indicate that another player touched it, therefore you shouldnāt modify the gravity?
LivignArt_SSN, is one of my avatar items. (that iām wearing).
isnāt āhitā is the HumanoidRootPart?
Then switch it to hit:FindFirstAncestorOfClass(āModelā) instead of hit.Parent. Didnāt realize your debounce was a one time use(which it really doesnāt need to be) because you never sent the full script.