First, there are a lot of problems.
Detect isn't needed because when the Brick is cloned all the children in the brick. Children are objects inside of the brick in the family tree. We need detect for the event, but we could do Brick.ClickDetecter.MouseClick
instead.
Now about Color3. Color3 doesn't go up to 255. The only numbers that you can have in a Color3 Value is 1 or 0. To get a number like 135, you need to do this. Color3.new(135/255,135/255,135/255)
. 1 is the same as 255 and 0 is the same as 0.
Another problem is the "PP". What are the chances of a person named "Player" going to join the game? Instead do something like this to choose a random player maybe: game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())]
. If this were a local script you could use local player. But in this case, since function "lol" is a text button you can't actually get the player from there.
Another problem is the variable PP
. Since the variable is a property not an actual value, you need to do this instead. PP=game.Players.Player.Character.Torso
BackIG.Position=PP.Position
03 | function putBrickValueInInventory(player) |
04 | game.StarterGui.ScreenGui.TextLabel.BackgroundColor 3 = Color 3. new( 1 , 1 , 1 ) |
05 | local Brick 2 = Brick:Clone() |
06 | Brick 2. Parent = game.ServerStorage |
11 | local BackIG = game.ServerStorage.Part:Clone() |
12 | BackIG.Parent = game.Workspace |
13 | local PP = game.Players.Player.Character.Torso.CFrame |
14 | BackIG.Position = PP.Position |
17 | Brick.ClickDetector.MouseClick:connect(putBrickValueInInventory) |
18 | game.StarterGui.ScreenGui.TextButton.MouseButton 1 Click:connect(Lol) |
EDIT
Well, if you want the brick to disappear if the brick is already in:
03 | function putBrickValueInInventory(player) |
04 | game.StarterGui.ScreenGui.TextLabel.BackgroundColor 3 = Color 3. new( 1 , 1 , 1 ) |
05 | local Brick 2 = Brick:Clone() |
06 | Brick 2. Parent = game.ServerStorage |
11 | local BackIG = game.ServerStorage.Part:Clone() |
12 | if not workspace.Part then |
13 | BackIG.Parent = game.Workspace |
14 | local PP = game.Players.Player.Character.Torso.CFrame |
15 | BackIG.Position = PP.Position |
17 | workspace.Part:Destroy() |
21 | Brick.ClickDetector.MouseClick:connect(putBrickValueInInventory) |
22 | game.StarterGui.ScreenGui.TextButton.MouseButton 1 Click:connect(Lol) |
Do some variation of this. Because what are the chances of a part named "Part" and the name is Completely different from other parts names.