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: Script Help :S

Previous Thread :: Next Thread 
PROJEKTSAO2 is not online. PROJEKTSAO2
Joined: 17 Nov 2014
Total Posts: 2
11 Jan 2015 12:18 PM
I've created a SurfaceGUI button that (using a local script) is supposed to clone a GUI from lighting into the player who clicked it's PlayerGui but it isn't working..
This is my script, any help would be appreciated.


contents = game.Players.LocalPlayer.PlayerGui.InventoryContentsNumber

function SwordObtain()
if contents.Value < 51 then
local Sword = game.Lighting.Weapons.Sword:Clone()
Sword.Parent = game.Players.LocalPlayer.PlayerGui.InventoryGUI.Main.ScrollingFrame
contents.Value = (contents.Value + 1)
local value = (contents.Value * 100)
Sword.Position = UDim2.new(0.01, 0, 0.003 , ((value - 100)+(contents.Value * 5)))
else
local alert = game.Lighting.INVENTORYFULL:Clone()
alert.Parent = game.Players.LocalPlayer.PlayerGui
end
end

script.Parent.MouseButton1Click:connect(SwordObtain)
Report Abuse
Poloboy567 is not online. Poloboy567
Joined: 24 Jun 2008
Total Posts: 62
11 Jan 2015 01:23 PM
Put this inside of a local script and put the script inside of StarterGui. Then, go to the last line of this code and specify the location of the button you want to click to call the function:

local player = game.Player.LocalPlayer

function SwordObtain()
local contents = player.PlayerGui.InventoryContentsNumber
if contents.Value < 51 then
local Sword = game.Lighting.Weapons.Sword:Clone()
Sword.Parent = player.PlayerGui.InventoryGUI.Main.ScrollingFrame
contents.Value = (contents.Value + 1)
local value = (contents.Value * 100)
Sword.Position = UDim2.new(0.01, 0, 0.003 , ((value - 100)+(contents.Value * 5)))
else
local alert = game.Lighting.INVENTORYFULL:Clone()
alert.Parent = player.PlayerGui
end
end

game.Workspace.Part.SurfaceGui.TextButton.MouseButton1Click:connect(SwordObtain) --Specify the location of the button in Workspace. This is an example.
Report Abuse
PROJEKTSAO2 is not online. PROJEKTSAO2
Joined: 17 Nov 2014
Total Posts: 2
17 Jan 2015 06:44 AM
Thanks for the help! Just couldn't figure out how to access PlayerGUI.
Just fixed the first line of code for anyone else reading, it should be:
local player=game.Players.LocalPlayer
Poloboy567 just missed an s by mistake.
Thanks again!
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