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: Why doesn't this script work in server, but works studio?

Previous Thread :: Next Thread 
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 09:46 AM
This script plays a sound when the players health changes, it is a local script in the starter pack

local humanoid = (game.Players.LocalPlayer.Character or game.Players.LocalCharacter.characterAdded:wait()):waitForChild("Humanoid")

humanoid.healthChanged:connect(function(_)
script.Sound:play()
end)
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
06 Feb 2016 09:48 AM
welcome to roblox
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 09:55 AM
Error message: Character is not a valid member of DataModel

Updated script:
local humanoid = (game.Players.LocalPlayer.Character or game.Players.LocalCharacter.characterAdded:wait()):WaitForChild("Humanoid")

humanoid.HealthChanged:connect(function(_)
script.Sound:play()
end)
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:01 AM
bump
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
06 Feb 2016 10:08 AM
there's no way this works in studio....
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
06 Feb 2016 10:09 AM
this is so wrong on so many levels; that wouldn't even be the output

>.< troll?
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:31 AM
It works in studio, how is it wrong, the original script was yes, but I forgot some capitalization. That is in the updated script
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:34 AM
Bump
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:41 AM
bump.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
06 Feb 2016 10:43 AM
local p = game.Players.LocalPlayer
repeat wait() until p.Character ~= nil
local c = p.Character
local h = c.Humanoid

h.Health.Changed:connect(function(val)
script.Sound:play()
end)


#Code print("Narwhals are our future")
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:45 AM
@TheRobot

That does not work in studio or in server.
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 10:53 AM
Bump...
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
06 Feb 2016 11:01 AM
oops


local h = c:WaitForChild("Humanoid")
h.HealthChanged:connect(function()


fixes


#Code print("Narwhals are our future")
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 11:04 AM
It still does not work in server :/
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 11:17 AM
Bump
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 11:25 AM
Bump..
Report Abuse
RoboGuest3000 is not online. RoboGuest3000
Joined: 10 Mar 2011
Total Posts: 383
06 Feb 2016 12:00 PM
@Rip
I wrote this script, it does work in studio, it doesn't work in server because of a typo, what part of it makes you think it won't work?

@OP
I fixed the typo, and tested in a server.
I also had to add a wait because for some reason it was connecting the healthChanged event to a different humanoid...? Not sure whats going on.

wait()
local humanoid = (game.Players.LocalPlayer.Character or game.Players.LocalPlayer.Character.characterAdded:wait()):waitForChild("Humanoid")

humanoid.healthChanged:connect(function(_)
script.Sound:play()
end)
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
06 Feb 2016 12:10 PM
I fixed typos in the script already, but I haven't tried adding in a wait, thanks, I'll try that! Ya I don't think rip has an idea of what he is talking about with this though, it was fairly similar to the script I asked for help on and it makes a lot of sense
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
06 Feb 2016 12:11 PM
use this to define character
local char = plr.Character or plr.CharacterAdded:wait()




http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$346 Tx546 (づ ゚ ³ ゚)づ
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