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: ...

Previous Thread :: Next Thread 
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 04:59 PM
How come this works in play solo and not server?

Its a server script in workspace.

local cam = game.Workspace.CurrentCamera


game.Players.PlayerAdded:connect(function(p)
repeat wait() until p.CharacterAdded
p.Character:Destroy()
cam.CameraSubject = game.Workspace.CarMod
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = game.Workspace.CamObject.CFrame * CFrame.Angles(math.rad(-20),math.rad(-5),math.rad(0)) * CFrame.new(0,0,8)
end)
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
18 Jul 2015 05:00 PM
Is it local script :o
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
18 Jul 2015 05:01 PM
Your script need to be local to use it for client only. You dont want the whole server to look at your camera xD
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:01 PM
No, it doesnt even work with a local script.
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
18 Jul 2015 05:02 PM
Still it need to be in a local script
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
18 Jul 2015 05:03 PM
It explained why your camera worked in solo and not in a server.
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:03 PM
game.Players.PlayerAdded:connect(function(p)
local cam = game.Workspace.CurrentCamera
repeat wait() until p.CharacterAdded
p.Character:Destroy()
cam.CameraSubject = game.Workspace.CarMod
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = game.Workspace.CamObject.CFrame * CFrame.Angles(math.rad(-20),math.rad(-5),math.rad(0)) * CFrame.new(0,0,8)
end)

Thats in a local script now, but it doesnt even destroy the character now.

Before it destroyed the character, but didnt move the camera (bc it was a server script)
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:11 PM
bmp
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:20 PM
b0mpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

halp
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:24 PM
I guess no ones gonna halp.
#ForeverAlun
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 05:43 PM
bmpp[2]
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 10:26 PM
GRSGRFEREW4T4T4TREFESFWADQwdqdwafesg
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 10:29 PM
Players service can only be used from a script, while CurrentCamera can only be used from a localscript. You are trying to use both client and server code in one script. Please read the wiki for more information.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
18 Jul 2015 10:29 PM
Must be in a local script, now wait for the character or something,

(at the top)
if game.Players.LocalPlayer.Character == nil then
game.Players.LocalPlayer.CharacterAdded:wait()
end

will fix it
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 10:30 PM
Seriously? Was there an update to it?

Players service USED to work fine in a local script...
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
18 Jul 2015 10:30 PM
"Players service can only be used from a script"
this is entirely incorrect, however you must be using a local script to access the camera.
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 10:30 PM
@lord, I already wait for the character.
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 10:31 PM
Directly from wiki for PlayerAdded: "Fires when a player enters the game. This event does not fire for LocalScripts - use ChildAdded instead."
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
18 Jul 2015 10:33 PM
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local cam = game.Workspace.CurrentCamera

character:Destroy()
cam.CameraSubject = game.Workspace.CarMod
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = game.Workspace.CamObject.CFrame * CFrame.Angles(math.rad(-20),math.rad(-5),math.rad(0)) * CFrame.new(0,0,8)

using playerAdded in a local script isn't going to fire for you.
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
18 Jul 2015 10:33 PM
Nope, pear was right.

I put it inside a starter gui now it works.

local cam = game.Workspace.CurrentCamera


script.Parent.Parent.CharacterAdded:connect(function()
p = script.Parent.Parent
print("Player added! Waiting for character...")
repeat wait() print("Waiting...") until p.CharacterAdded
print("Character loaded!")
p.Character:Destroy()
cam.CameraSubject = game.Workspace.CarMod
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = game.Workspace.CamObject.CFrame * CFrame.Angles(math.rad(-20),math.rad(-5),math.rad(0)) * CFrame.new(0,0,8)
print("Done!")
end)
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
18 Jul 2015 10:33 PM
And you clearly said the Players service, not the PlayerAdded event :P
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
18 Jul 2015 10:34 PM
Players does work in a LS, but not pAdded. Use cAdded.

Also, CurrentCam can only be used in a LS.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
18 Jul 2015 10:36 PM
That's going to break as soon as more players start joining. Use the code I fixed for you, put it in a local script inside the startergui (will replicate to playergui so it can run). PlayerAdded should not be used in this situation.
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 10:37 PM
@lordrambo,

I've been up since 7 am this morning and didn't fall asleep until 3 am this morning. I haven't been double-checking my posts for errors, so it's my bad.
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