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
Brick=workspace.Part
function putBrickValueInInventory(player)
game.StarterGui.ScreenGui.TextLabel.BackgroundColor3=Color3.new(1,1,1)
local Brick2=Brick:Clone()
Brick2.Parent=game.ServerStorage
Brick:Destroy()
end
function Lol()
local BackIG=game.ServerStorage.Part:Clone()
BackIG.Parent=game.Workspace
local PP=game.Players.Player.Character.Torso.CFrame
BackIG.Position=PP.Position
end
Brick.ClickDetector.MouseClick:connect(putBrickValueInInventory)
game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(Lol)
EDIT
Well, if you want the brick to disappear if the brick is already in:
Brick=workspace.Part
function putBrickValueInInventory(player)
game.StarterGui.ScreenGui.TextLabel.BackgroundColor3=Color3.new(1,1,1)
local Brick2=Brick:Clone()
Brick2.Parent=game.ServerStorage
Brick:Destroy()
end
function Lol()
local BackIG=game.ServerStorage.Part:Clone()
if not workspace.Part then
BackIG.Parent=game.Workspace
local PP=game.Players.Player.Character.Torso.CFrame
BackIG.Position=PP.Position
else
workspace.Part:Destroy()
end
end
Brick.ClickDetector.MouseClick:connect(putBrickValueInInventory)
game.StarterGui.ScreenGui.TextButton.MouseButton1Click: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.
1 comment
You mean like if the brick is already in workspace?