Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 11:11 AM |
local Players = game:GetService("Players") local Player local Humanoid
Players.PlayerAdded:Connect(function(plr) Player = plr Humanoid = Player.Character.Humanoid end)
Trying to get the player in a regular script instead of a LocalScript.
|
|
|
| Report Abuse |
|
|
|
| 25 Mar 2017 11:14 AM |
You can do this
for _,v in pairs(game.Players:GetPlayers()) do --do stuff end |
|
|
| Report Abuse |
|
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 11:16 AM |
I don't quite understand what you mean.
|
|
|
| Report Abuse |
|
|
|
| 25 Mar 2017 11:18 AM |
| It will loop through all the players and run code inside the loop for the player. |
|
|
| Report Abuse |
|
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 11:30 AM |
I'm trying to get a Player Variable via function.
|
|
|
| Report Abuse |
|
|
|
| 25 Mar 2017 11:33 AM |
You shouldn't need to store a variable for each new player in the lowest scope. Use a function.
|
|
|
| Report Abuse |
|
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 11:36 AM |
Yes I want to use a function, but I don't know how to set it up. The script I showed above is my best attempt.
|
|
|
| Report Abuse |
|
|
|
| 25 Mar 2017 11:42 AM |
game:GetService("Players").PlayerAdded:Connect(function(player) local humanoid = (player.Character or player.CharacterAdded:Wait()).Humanoid end)
|
|
|
| Report Abuse |
|
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 11:52 AM |
Alright, and if I wanted to module that. How would I do it?
Module:
function SpeedModule.GetPlayer(plr) Humanoid = (plr.Character or plr.CharacterAdded:Wait()).Humanoid end
Script:
Players.PlayerAdded:Connect(function(plr) helperModule.GetPlayer(plr) end)
|
|
|
| Report Abuse |
|
|
| |
|
Rakonus
|
  |
| Joined: 19 Dec 2014 |
| Total Posts: 1004 |
|
|
| 25 Mar 2017 12:01 PM |
I'm going to private module a script that I am making. So that I can make good updates for everyone who uses it. Right now it is a simple speed script, but soon I hope to add stuff that limits jumping, and other things that help for the genre that I am in.
|
|
|
| Report Abuse |
|
|