Author Topic: Changing the global gravity (for players) with Entity:SetGravity() ?  (Read 576 times)

0 Members and 1 Guest are viewing this topic.

Offline FlyinC4T

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
alright so I have been trying out multiple times to get this to work.

Code: [Select]
--[[
    Gravity Settings--]]
hook.Add("PlayerSpawn", "wzm:GlobalGravity", function()
    Player:SetGravity(100)
end)

basically it's supposed to set the global gravity for all players. I would use PlayerConnect aswell, but before that I have to make the PlayerSpawn work first.

(I have a bunch of E2 experience and I am aware that it is NOT the same, that being said I should be able to understand at least some stuff)

The Error:
Code: [Select]
lua:4: attempt to index global 'Player' (a function value)

IF IT IS NOT POSSIBLE (read me)
then please do show me alternative ways
« Last Edit: February 15, 2022, 09:15:14 AM by FlyinC4T »

Offline DerMetelGamerYT

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Changing the global gravity (for players) with Entity:SetGravity() ?
« Reply #1 on: February 16, 2022, 04:10:31 AM »
Hi, you should try this:

Code: [Select]
--[[Gravity Settings--]]
hook.Add("PlayerSpawn", "wzm:GlobalGravity", function(player)
    player:SetGravity(100)
end)

Offline Codingale

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Changing the global gravity (for players) with Entity:SetGravity() ?
« Reply #2 on: April 22, 2022, 08:29:03 PM »
Hi, you should try this:

Code: [Select]
--[[Gravity Settings--]]
hook.Add("PlayerSpawn", "wzm:GlobalGravity", function(player)
    player:SetGravity(100)
end)

I advise newcomers to Lua to avoid using globals such as player as if they overwrite the player table they can no longer use things like player.GetAll() and so on, and sometimes they won't even know what's wrong. In most cases I use pl, or ply