generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What's wrong with this??

Previous Thread :: Next Thread 
Rakonus is not online. 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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
25 Mar 2017 11:14 AM
You can do this

for _,v in pairs(game.Players:GetPlayers()) do
--do stuff
end
Report Abuse
Rakonus is not online. Rakonus
Joined: 19 Dec 2014
Total Posts: 1004
25 Mar 2017 11:16 AM
I don't quite understand what you mean.


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
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 is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
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 is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
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 is not online. 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
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
25 Mar 2017 11:53 AM
Why


Report Abuse
Rakonus is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image