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
 

Re: Works in testmode but not in servers!

Previous Thread :: Next Thread 
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 01:24 PM

Okay so I got this and it works perfectly fine in testmode but it doesn't do anything at all in a normal server, does anyone know what is the problems
Thing to know:
-This is in a localscript
-This is inside startergui

----------------------------------------------------------------

player = game.Players.LocalPlayer
system = game.workspace.system

function onDeath()
system.playersalive.Value = system.playersalive.Value -1
player.CameraMode="Classic"
system.joindeadmsg.Value = player.Name .. " has died."
end

player.Character.Humanoid.Died:connect(onDeath)
Report Abuse
Joe11Joe99 is not online. Joe11Joe99
Joined: 22 May 2011
Total Posts: 34458
13 May 2014 01:49 PM
insert the script into the character or into playergui DURING the game
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
13 May 2014 01:50 PM
local player = game.Players:WaitForChild('LocalPlayer');

Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 02:06 PM
@Verified

thought that would fix it, but it didn't for some reason..
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 02:33 PM
Help..
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:36 PM
To test it as if it's a normal server;

For old studio:
Start a server, then start as many players as you would like.
(From the place not from the server)

For new studio (Ribbon bar)
Click the 'Test' ribbon, and at the right select the drop down menu. Select how many players you would like to test, and click 'Start'

After you do this tell us the output.
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 02:48 PM
OUTPUT:
14:46:41.106 - Players.Player1.PlayerGui.maingui.ondead:10: attempt to index field 'Character' (a nil value)
14:46:41.106 - Stack Begin
14:46:41.107 - Script 'Players.Player1.PlayerGui.maingui.ondead', Line 10
14:46:41.108 - Stack End
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 02:51 PM
The script is most likely running before the character is even added, you can fix this with an if.
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 03:13 PM
and where should I put this "if"
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 03:49 PM
Cmon how can I make it wait for the character to load?
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
13 May 2014 03:51 PM
Using PlayerAdded, clone the script into the player. It's beacuse it's executing before the character is there
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 04:12 PM
i'm sure there must be a easier way to do it than cloning it to each player..
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
13 May 2014 04:20 PM
You could :WaitForChild
Report Abuse
yoshiwars is not online. yoshiwars
Joined: 27 Jul 2009
Total Posts: 216
13 May 2014 04:31 PM
I tried this
player = game.Players:WaitForChild('LocalPlayer')
but it didnt seem to work
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
13 May 2014 04:35 PM
LocalPlayer will always be there, since the Backpack and/or PlayerGui scripts will only fire when the player is there. The things you have to wait for are things like Character and Humanoid. Like this

if game.Players.LocalPlayer.Character then
v.Character:WaitForChild("Humanoid")
end
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