Hello! How can I make a script where when I press a button, it prints everyones gravity value. I know that you might think "Everyone will have the same gravity" but not in my game. I want it to print everyones value and if the value is not 199, or whatever the default value is, the value will be a different color. I know this site shouldn't really be used to request scripts to be made but I really can't figure out how to do it...
Example:
User1: 199 User2: 199 User3: 234 etc.
next time you ask, you should have already attempted to make a script so we can fix it instead of making you scripts. local script can go inside starterplayerscripts, server in serverscriptservice
this script may have errors as I didn't write it in studio or test it but you can edit and fix errors. should be using a remote function
-- this part in a server script while wait(100) do -- runs every 100 sec for i,v in pairs(game.Players:GetPlayers()) do local playerGravity = game.ReplicatedStorage.Events.GetGravity:InvokeClient(v) -- will need to make some of this stuff print(playerGravity) --[[ if you want playername: gravity do print(v.Name .. ': ' .. playerGravity) ]] end end ================= different script ==================== -- this in a local function game.ReplicatedStorage.Events.GetGravity.OnClientInvoke() return game.Workspace.Gravity -- forgot what the gravity was called u can edit if wrong end
-- code on the server local valuelogger = Instance.new("RemoteEvent",game:GetService("ReplicatedStorage")) valuelogger.Name = "requester" local yourbutton = yourbuttonhere yourbutton.MouseButton1Down:Connect(function() valuelogger:FireAllClients("getlocalgravity") end) local commands = { ["gravityvalue"] = function(player,...) local args = {...} local gravity = args[1] if typeof(gravity) ~= "number" then player:Kick("invalid arguments") print(player.Name .. " gave invalid arguments for the gravity get command") else print("gravity for "..player.Name..": "..tostring(gravity)) end end, } valuelogger.OnServerEvent:Connect(function(plr,...) local args = {...} local commandrecieved = false for i,v in pairs(commands) do if args[1] == i then table.remove(args,1) commandrecieved = true v(plr,args) end end if commandrecieved == false then plr:Kick("invalid remote arguments") end end) -- code on the client local requesterremote = game:GetService("ReplicatedStorage"):WaitForChild("requester") local funcs = { ["getlocalgravity"] = function() requesterremote:FireServer("gravityvalue",workspace.Gravity) end, } requesterremote.OnClientEvent:Connect(function(request) for i,v in pairs(funcs) do if request == i then v() end end end)
i know this is not entirely secure but it will print every player's local gravity value from the client on the server
reply to me if there are any errors or incorrect kicks
@MLGwarfare04 What do I do with the script? What do I put where? What lines do I need to change? Please help. Thanks!