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: ZoomRestriction Tutorial for Newbies

Previous Thread :: Next Thread 
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 08:55 PM
Right, so before we get started, I want to thank crazyman32 for opening his ZoomRestrictions model, for that helped me learn.
**What is ZoomRestriction?**
Well, ZoomRestriction is a feature that lets you make it so a player can't zoom out to a certain restriction. This uses a script that tells when the player has zoomed out, and activates a GUI that usually says "Zoom in" or "Zoom in to play", but again, you can make it say whatever you want.
**Getting Started**
Open up Studio, (Start ​> All Programs ​> ROBLOX ​> Roblox Studio.) and start a blank place (File ​> New) and at the top click Insert ​> Object ​> Script. Now, lets get started for real.
**Starting The Script**
Name the script "Handling". Then add this:

    game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function()
        wait(0.5)
        script.Cam:clone().Parent = p.Character
    end)
end)

I don't want to explain what it's doing to in-depth, for fear of confusing you, but lets just say that it waits for a player to come into the game, then starts.
Now, highlight the script and go to Insert ​> Object ​> LocalScript. LocalScripts run client side, they differ a lot from normal scripts, just to give some background info. Label this LocalScript "Cam", and add this into it:

    wait(0.1)
local maxZoom = 50
local cam = game.Workspace.CurrentCamera
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local gui
while (not gui) do gui = script:findFirstChild("CamGui") wait() end
gui.Parent = player.PlayerGui

function loop()
    while ((player.Character) and (player.Character:findFirstChild("Head"))) do
        local dist = (cam.CoordinateFrame.p-player.Character.Head.Position).magnitude
        gui.Screen.Visible = (dist ​> maxZoom)
        wait(0.2)
    end
end

loop()

Where it says local maxZoom = 50, change that to the amount you want the player to zoom out, in studs. Now, this isn't finished. We have to make the GUI that appears when the player zooms out!
Click the LocalScript and go to Insert ​> Object ​> ScreenGui. Now name the ScreenGui, "CamGui" without the quotes and click it and go to Insert ​> Object ​> Frame. Rename the Frame "Screen", without the quotes, and click on it and look into the Properties box. (Don't see it? View ​> Properties.) Now, Active should be unchecked, if not uncheck it, make the BackgroundColor3 whatever you want the color to be, BackgroundTransparency should be 0, Make the BorderColor the same as the BackgroundColor3, make the BorderSizePixel be 1, now make the Position {0,-2},{0,-2} and the size {1,4},{1,4}. Make the style Custom, and then go to Insert ​> Object ​> TextLabel. Now here's what the properties you should make for TextLabel are:
Active: Unchecked
BackgroundColor3: Whatever you want the text color to be
BackgroundTransparency: 0
BorderColor3: Whatever you want it to be
BorderSizePixel: 1
Position: {0.5,0},{0.5,0}
Size: {0,0},{0,0}
Visible: Checked
Font: ArialBold
FontSize: 24
Text: Please zoom in to play, Zoom in now, etc,etc.
TextColor3: Whatever.
TextStrokeColor: Whatever.
TextStrokeTransparency: 1
TextTransparency: 0
TextWrapped: Unchecked
TextXAlignment: Center
TextYAlignment: Same as above.
Now you're done! Save it ass a model, or add a baseplate and test!

Happy Scripting!

-GD987
Report Abuse
xXStealthsniper200Xx is not online. xXStealthsniper200Xx
Joined: 30 Nov 2011
Total Posts: 2037
20 May 2012 09:09 PM
Dude you need to start a school or leave links on your profile description to these things.

To me there's these levels.

Beginner
Intermediate
Advanced
Master <-- You fit here. :)

(There is one more level I forgot...)
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:31 PM
It's called Legendary....

And thanks, I'm making more :D








~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
20 May 2012 09:31 PM
This is just a simple distance check...

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
mage11561 is not online. mage11561
Joined: 03 Sep 2008
Total Posts: 13217
20 May 2012 09:32 PM
I learned absolutely nothing from this,

perhaps next time tell us what to do rather than doing it for us.

And to think I actually wanted to learn this >.>
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 May 2012 09:35 PM
"I don't want to explain what it's doing to in-depth, for fear of confusing you"

That's what tutorials are for... To things clear up help people, not just give out the code...

† KMXD †
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
20 May 2012 09:36 PM
This is literally my code that I wrote over a year ago :P
Report Abuse
mage11561 is not online. mage11561
Joined: 03 Sep 2008
Total Posts: 13217
20 May 2012 09:36 PM
"That's what tutorials are for... To things clear up help people, not just give out the code..."

this
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:46 PM
Yes, crazy, I gave credit because your script gave me the info I used to learn this.

And perhaps some of you should read the title "Tutorial for NEWBIES". I don't expect complete beginners to understand what everything in the script is doing.

Atleast not yet.







~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 May 2012 09:47 PM
"To things clear up help people, not just give out the code..."

Wow, I completely screwed that sentence up...

To clear things up/help people, not just give out the code...

† KMXD †
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 May 2012 09:48 PM
Yes, but people would just copy/paste the script, and probably wouldn't try understanding it.

† KMXD †
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:49 PM
Since they are newbies, they shouldn't know anything, therefore I would have to explain lots of other things before I could clear this up. And then maybe I'll make one for you guys that already know enough Lua.









~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:50 PM
Yes, I see that problem, but the point is to have it for future reference, and to try and look at how everything works.

Yes, I will try and explain what everything does more often, however not too much, seeing as they might not understand completely.







~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
rayoma is not online. rayoma
Joined: 13 Nov 2009
Total Posts: 1911
20 May 2012 09:51 PM
xXStealthsniper200Xx wrote:
> To me there's these levels.
Beginner
Intermediate
Advanced
Master <-- You fit here. :)
(There is one more level I forgot...)

GreenDay987 wrote:
> It's called Legendary....


Never heard of this scale...
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:53 PM
I'm just guessing that's what it is...

And I prefer a comfortable Intermediate or Advanced :P... not really Master yet...




~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
20 May 2012 09:55 PM
I found a typo...

I put "as" with another "s"...

Hope I don't get banned.




~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
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