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