|
| 12 Aug 2014 07:28 AM |
I have this part of a Local script which is suppose to effect all players in the game. It works when I play by myself in a server, but as soon as another player joins, it doesn't work at all. Can anyone tell me what I'm doing wrong?
for i, v in pairs(Game.Players:GetChildren()) do if v.ClassName == "Player" then v.PlayerGui.Sounds.Music:Stop() v.PlayerGui.Sounds.StartOfUltiSound:Play() v.Character.Torso.Anchored = true cam = script.Camera:Clone() -- Camera Script which changes all player's camera to the user cam.Parent = v.Backpack creator=Instance.new("ObjectValue") creator.Name="PlayerName" creator.Value=Player.Character creator.Parent = cam wait(1) v.PlayerGui.Sounds.UltimateMusic.SoundId = "http://www.roblox.com/asset/?id=142963210" v.PlayerGui.Sounds.UltimateMusic:Play() cam.Disabled = false end end |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 Aug 2014 07:32 AM |
for i, v in pairs(Game.Players:GetChildren()) do if v.ClassName == "Player" then
Since the only members of Players are Player instances, then that if statement will always be true. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2014 07:35 AM |
| But that wouldn't mess up the script, would it? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 Aug 2014 07:36 AM |
| I don't know if it does or not, most likely the latter, but it's unnecessary, and I'd advice removing it anyway. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 Aug 2014 07:36 AM |
| You can't clone cameras and expect them to work on other people. What you should do instead is just set the CameraSubject to that person's HumanoidRootPart instead. |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 12 Aug 2014 07:39 AM |
| Yes. Use a LocalScript and get the game.Workspace.CurrentCamera. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2014 07:41 AM |
The Camera part is a script that clones into all of the player's backapacks which does that, maybe I should have explained that earlier XD
This is the Camera script
local player = Game.Workspace:findFirstChild(script.PlayerName.Value) local cam = game.Workspace.CurrentCamera local StarterGui = Game:GetService('StarterGui') while true do wait() cam.CameraSubject = player.Head cam.CoordinateFrame = CFrame.new(player.Head.Position)* CFrame.new(0, 0, 15) wait(6) cam.CameraSubject = game.Players.LocalPlayer.Character.Head cam.CameraType = 4 wait(1) script:remove() end
|
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 12 Aug 2014 07:44 AM |
Play the game with someone, then press F9 and read the output in the Local section, it should tell you any errors there.
http://www.roblox.com/Forum/ShowPost.aspx?PostID=142193675 |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2014 08:00 AM |
Never knew that feature existed, I was using a script all that time. It says that PlayerGui isn't in the Player (Line 1151) ._. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
|
| 12 Aug 2014 08:11 AM |
v.PlayerGui.Sounds.Music:Stop()
This script is over 1,600 lines long XD |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 12 Aug 2014 08:12 AM |
http://wiki.roblox.com/index.php?title=RBX.lua.PlayerGui_(Object)
"The PlayerGui object is a container that holds a Player's user GUI.
When a player spawns, the contents of the StarterGui are copied into the Player's PlayerGui. Objects can also be parented under the PlayerGui directly. Once a Player dies, the PlayerGui is removed."
Is this script running when a player dies ? |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2014 08:30 AM |
| No, it's running while the player is alive. |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 12 Aug 2014 09:30 AM |
Yeah, that's been happening to me too when I've been trying to access another player's PlayerGui to set a NumberValue inside it.
It seems that LocalScripts can't access anything else besides "Local" stuff and Game's descendants. So I had to use a ServerScript(Normal) to do it, because that can access everything.
Might be hard to move though. :/
http://www.roblox.com/Forum/ShowPost.aspx?PostID=142193675 |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2014 10:06 AM |
I guess what I'll have to do is make it activate a script which puts the camera script into everyone's PlayerGui. Meaning I'll have to make a middle point script XD |
|
|
| Report Abuse |
|
|