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: What's wrong with this?

Previous Thread :: Next Thread 
OldGoldie is not online. OldGoldie
Joined: 17 Aug 2010
Total Posts: 8210
04 Oct 2013 02:51 AM
local char = game.Players.LocalPlayer.Character

while wait() do
if char:FindFirstChild("Fake Head") then
Workspace.CurrentCamera.CoordinateFrame = char["Fake Head"].CFrame.X - 10
end
end

It's in a local script in startergui
No output
Report Abuse
BLOXLUA is not online. BLOXLUA
Joined: 16 Mar 2013
Total Posts: 453
04 Oct 2013 07:27 AM
Always put an "else" or an "elseif" in a conditional statement, just in case.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
04 Oct 2013 07:42 AM
Scripts do not run in the StartGui.

If you are running this in the PlayerGui, try this.

--

local char = game.Players.LocalPlayer.Character

while wait() do
if char:FindFirstChild("Fake Head") then
Workspace.CurrentCamera.CoordinateFrame = char["Fake Head"].CFrame.X - 10
else
print ("Fake Head is nil")
end
end

--If the output prints "Fake Head is nil", this means your if statement is false, thus why you were reading no output to begin with.
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
04 Oct 2013 07:46 AM
@Killer
If it's in the StarterGui it will automatically go to players' PlayerGui.

Also, I think this line

Workspace.CurrentCamera.CoordinateFrame = char["Fake Head"].CFrame.X - 10

is wrong, because you set the CoordinateFrame to only one number instead of 3.
Report Abuse
KillerKyle is online. KillerKyle
Joined: 29 Jul 2007
Total Posts: 6371
04 Oct 2013 07:53 AM
Though you are correct, if that were the issue, and output would have printed. You pointing this out has proven that the if statement is false, therefore "Fake Head" is infact nil, or does not exist.

Workspace.CurrentCamera.CoordinateFrame = char["Fake Head"].CFrame.X - 10

Should be..

Workspace.CurrentCamera.CoordinateFrame = char["Fake Head"].CFrame - Vector3.new (10, 0, 0)
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