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 » Scripting Helpers
Home Search
 

PlayerAdded trouble! Please help!

Previous Thread :: Next Thread 
itachi5036 is not online. itachi5036
Joined: 19 Apr 2009
Total Posts: 481
27 Jul 2013 02:57 AM
Why won't this work?

game.Players.PlayerAdded:connect(function(player)
player.Character.Humanoid.WalkSpeed = 0
end)


It should be working fine I thought...
Report Abuse
777MrEpic is not online. 777MrEpic
Joined: 17 Oct 2012
Total Posts: 3998
27 Jul 2013 02:59 AM
leastn = 0
function ok(aplayer)
aplayer.Character.Humanoid.WalkSpeed = leastn
end
game.Players.PlayerAdded:connect(ok)
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Jul 2013 03:10 AM
Use WaitForChild.
Report Abuse
noliCAIKS is not online. noliCAIKS
Joined: 08 Mar 2010
Total Posts: 917
27 Jul 2013 04:51 AM
You're all doing it wrong.
I'll write you something neat.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
27 Jul 2013 04:52 AM
game.Players.PlayerAdded:connect(function(plyr)
repeat wait() until plyr.Character
plyr.Character.Humanoid.WalkSpeed = 0
end)
Report Abuse
noliCAIKS is not online. noliCAIKS
Joined: 08 Mar 2010
Total Posts: 917
27 Jul 2013 04:58 AM
It's done. Here you go:

local Players = Game:GetService("Players")

function DisableWalking(character)
    local humanoid = WaitForChildByClass(character, "Humanoid")
    humanoid.WalkSpeed = 0
end
function WaitForChildByClass(parent, typename)
    for _, child in ipairs(parent:GetChildren()) do
        if child:IsA(typename) then
            return child
        end
    end
    local child
    repeat
        child = parent.ChildAdded:wait()
    until child:IsA(typename)
    return child
end

Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(DisableWalking)
end)
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
27 Jul 2013 04:59 AM
Doubt he wanted the player to spawn with 0 WalkSpeed all the time.
Report Abuse
noliCAIKS is not online. noliCAIKS
Joined: 08 Mar 2010
Total Posts: 917
27 Jul 2013 05:03 AM
Ah, if you want it to happen only once, use this:

local Players = Game:GetService("Players")

function DisableWalking(character)
    local humanoid = WaitForChildByClass(character, "Humanoid")
    humanoid.WalkSpeed = 0
end
function WaitForChildByClass(parent, typename)
    for _, child in ipairs(parent:GetChildren()) do
        if child:IsA(typename) then
            return child
        end
    end
    local child
    repeat
        child = parent.ChildAdded:wait()
    until child:IsA(typename)
    return child
end

Players.PlayerAdded:connect(function(player)
    DisableWalking(player.CharacterAdded:wait())
end)
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
27 Jul 2013 05:06 AM
Or, shorter and simpler:
game.Players.PlayerAdded:connect(function(plr)
plr:WaitForChild("Character")
Character.Humanoid.Walkspeed = 0
end)
Report Abuse
noliCAIKS is not online. noliCAIKS
Joined: 08 Mar 2010
Total Posts: 917
27 Jul 2013 05:10 AM
@sam8985
Character is not a while. Also, that is unreliable. If you want it simple but stable, use this:

Game:GetService("Players").PlayerAdded:connect(function(player)
    player.CharacterAdded:wait():WaitForChild("Humanoid").Walkspeed = 0
end)
Report Abuse
noliCAIKS is not online. noliCAIKS
Joined: 08 Mar 2010
Total Posts: 917
27 Jul 2013 05:11 AM
*child, instead of while. What the heck.
Report Abuse
iIikeyou is not online. iIikeyou
Joined: 07 Mar 2012
Total Posts: 1659
27 Jul 2013 05:12 AM
local function d(o)
o.Humanoid.WalkSpeed=0
end
game.Players.PlayerAdded:connect(function(p)
repeat wait()until p.Character
d(p.Character)
p.CharacterAdded:connect(d)
end)
Report Abuse
itachi5036 is not online. itachi5036
Joined: 19 Apr 2009
Total Posts: 481
27 Jul 2013 02:41 PM
Thank you all for the different ideas! I'll try em' out!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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