This is one of the scripts
01 | part = script.Parent |
02 |
03 |
04 | function collect(part 1 ) |
05 | part:Destroy() |
06 | print ( "bob" ) |
07 | part 1. Item.Coke.Value+ 1 |
08 |
09 | end |
10 |
11 | part.ClickDetector.MouseClick:connect(collect) |
Here is another.
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local Item = Instance.new( "Model" ) |
03 | Item.Name = "Item" |
04 | Item.Parent = player |
05 | wait( 1 ) |
06 | local Coke = Instance.new( "IntValue" ) |
07 | Coke.Name = "Coke" |
08 | Coke.Parent = player.Item |
09 |
10 | Coke.Value = 0 |
11 | end ) |
So basically what the first script wants is when you click the part it destroys itself and also adds a value to the player What the second one does is add a value into the player and this is the value that the first scripts adds onto. So the problem is it wont add. The addition sign in the first script has a red line under it but thats all i know.
To use addition to IntValues and all of that stuff you have to do it like this part1.Item.Coke.Value = part1.Item.Coke.Value + 1
.
And I am pretty sure that after you destroy the part where the script is held, the rest of the code won't execute.
First script
Your function "collect" has a parameter called "part1" so when calling it you have to define the parameter, silly!
1 | part.ClickDetector.MouseClick:connect(collect) -- NO PARAMETER |
2 | part.ClickDetector.MouseClick:connect(collect( --[[WHATEVER YOU WANT part1 TO BE]] )) |
Hehe
Otherwise line 4 of your function is not acting on anything and breaking the code, since Part1 is not defined
Second script
Item is a variable in your code as well as an item in the player so when calling
1 | player.Item |
Since you defined "Item" as "the player that joined's item" you are actually doing:
1 | Player.Player.Item |
Instead do
1 | .Parent = Item |