Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help on trying to make make a simple script that puts a brick in and out of SerevrStorage?

Asked by 10 years ago
01Detect=workspace.Part.ClickDetector
02Brick=workspace.Part
03 
04function putBrickValueInInventory(player)
05game.StarterGui.ScreenGui.TextLabel.BackgroundColor3=Color3.new(255, 255, 255)
06local Brick2=Brick:Clone()
07Brick2.Parent=game.ServerStorage
08Brick:remove() 
09end
10 
11function Lol()
12local BackIG=game.ServerStorage.Part:Clone()
13BackIG.Parent=game.Workspace
14local PP=game.Players.Player.Character.Torso.CFrame
15BackIG.Position=Vector3.new(PP)
16end
17 
18Detect.MouseClick:connect(putBrickValueInInventory)
19game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(Lol)

It works up to when I click the brick, it clones the brick into the ServerStorage, but the color of the TextButton in the Gui, doesn't change color. Also, when I click the button, it doesnt put the brick back into the workspace. Help please?

0
You mean like if the brick is already in workspace? EzraNehemiah_TF2 3552 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

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

01Brick=workspace.Part
02 
03function putBrickValueInInventory(player)
04game.StarterGui.ScreenGui.TextLabel.BackgroundColor3=Color3.new(1,1,1) --Same as 255,255,255
05local Brick2=Brick:Clone()
06Brick2.Parent=game.ServerStorage
07Brick:Destroy() --Remove doesn't get rid of the brick. If you do Brick.Parent = workspace after Brick:remove() it will still come back. 
08end
09 
10function Lol()
11local BackIG=game.ServerStorage.Part:Clone()
12BackIG.Parent=game.Workspace
13local PP=game.Players.Player.Character.Torso.CFrame
14BackIG.Position=PP.Position
15end
16 
17Brick.ClickDetector.MouseClick:connect(putBrickValueInInventory)
18game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(Lol)

EDIT

Well, if you want the brick to disappear if the brick is already in:

01Brick=workspace.Part
02 
03function putBrickValueInInventory(player)
04game.StarterGui.ScreenGui.TextLabel.BackgroundColor3=Color3.new(1,1,1) --Same as 255,255,255
05local Brick2=Brick:Clone()
06Brick2.Parent=game.ServerStorage
07Brick:Destroy() --Remove doesn't get rid of the brick. If you do Brick.Parent = workspace after Brick:remove() it will still come back. 
08end
09 
10function Lol()
11local BackIG=game.ServerStorage.Part:Clone()
12if not workspace.Part then
13BackIG.Parent=game.Workspace
14local PP=game.Players.Player.Character.Torso.CFrame
15BackIG.Position=PP.Position
View all 22 lines...

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.

0
+1 for good answer Mystdar 352 — 10y
0
Thanks EzraNehemiah_TF2 3552 — 10y
0
How would I amke it so, if any player clickss the brick, it would go into the serever storage? XrxShadowxX 0 — 10y
Ad

Answer this question