I'm trying to make a shop GUI for a little game I'm making, and it was working fine but then I realized it was just moving a tool to the player backpack rather than cloning it. After I tried to do that it broke and now it just says
"Attempt to connect failed: Passed value is not a function"
Then when I click it, it says
"attempt to call a nil value"
I just want to add that I'm quite new and don't know much about scripting
Script:
01 | player = script.Parent.Parent.Parent.Parent.Parent.Parent |
02 | local scriptOn = false |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local item = game RS:WaitForChild( "Milk" ) |
05 |
06 | if game.Players.LocalPlayer.leaderstats.Dollaroos.Value > = 15 then scriptOn = true else scriptOn = false |
07 | if scriptOn then |
08 | function Click(mouse) |
09 | local newMilk = item:Clone() |
10 | newMilk.Parent = player.Backpack |
11 | newMilk.Parent = player.StarterGear |
12 | game.Players.LocalPlayer.leaderstats.Dollaroos.Value = game.Players.LocalPlayer.leaderstats.Dollaroos.Value - 15 |
13 | scriptOn = false |
14 | end |
15 | end |
16 | end |
17 |
18 | script.Parent.MouseButton 1 Down:connect(Click) |
I think you forgot a period between game and replicated storage in line 4! If thats not the case, sorry, I suck at scripting as well.
EDIT: So basically the script should be
01 | player = script.Parent.Parent.Parent.Parent.Parent.Parent |
02 | local scriptOn = false |
03 | local RS = game:GetService( "ReplicatedStorage" ) |
04 | local item = game.RS:WaitForChild( "Milk" ) |
05 |
06 | if game.Players.LocalPlayer.leaderstats.Dollaroos.Value > = 15 then scriptOn = true else scriptOn = false |
07 | if scriptOn then |
08 | function Click(mouse) |
09 | local newMilk = item:Clone() |
10 | newMilk.Parent = player.Backpack |
11 | newMilk.Parent = player.StarterGear |
12 | game.Players.LocalPlayer.leaderstats.Dollaroos.Value = game.Players.LocalPlayer.leaderstats.Dollaroos.Value - 15 |
13 | scriptOn = false |
14 | end |
15 | end |
16 | end |
17 |
18 | script.Parent.MouseButton 1 Down:connect(Click) |