Ok my basic shop script needs to send a script to the player's backpack. (I have starter gear too cause that's how I remember to make these kinda scripts) But when the player buys the item, it sends the script, instead of a copy. If another player tries to buy theitem it says "SlvrEnable Is not a valid member of replicated storage" and they cant get it. Any idea on what I'm doing wrong? If its filtering enabled I will cry cause I'm good at it XD.
01 | SlvrEnable = game.ReplicatedStorage.SlvrEnable |
02 | game.ReplicatedStorage.SlvrPurchase.OnServerEvent:Connect( function (Player) |
03 | if Player.leaderstats.Coins.Value > = 25 then |
04 |
05 | Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value - 25 |
06 | Player:WaitForChild ( "Backpack" ) |
07 | game.ReplicatedStorage.SlvrEnable:Clone()SlvrEnable.Parent = Player.Backpack |
08 | game.ReplicatedStorage.SlvrEnable:Clone()SlvrEnable.Parent = Player.StarterGear |
09 | else |
10 | print ( "not enough money" ) |
11 | end |
12 | end ) |
There is an error on lines 7 and 8. You don't put the name after :Clone(), just the .Parent
Updated Code:
01 | local SlvrEnable = game.ReplicatedStorage.SlvrEnable |
02 | game.ReplicatedStorage.SlvrPurchase.OnServerEvent:Connect( function (Player) |
03 | if Player.leaderstats.Coins.Value > = 25 then |
04 |
05 | Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value - 25 |
06 | local Backpack = Player:WaitForChild ( "Backpack" ) |
07 | game.ReplicatedStorage.SlvrEnable:Clone().Parent = Backpack |
08 | game.ReplicatedStorage.SlvrEnable:Clone().Parent = Player.StarterGear |
09 | else |
10 | print ( "not enough money" ) |
11 | end |
12 | end ) |
Well, you treated the variable 'SlvrEnable' as it has been cloned in two places...
1 | game.ReplicatedStorage.SlvrEnable:Clone()SlvrEnable.Parent = Player.Backpack |
1 | game.ReplicatedStorage.SlvrEnable:Clone()SlvrEnable.Parent = Player.StarterGear |
You have made the Clone but you are not using it I would do this...
1 | local Clone = SlvrEnable:Clone() |
2 | Clone.Parent = Player.StarterGear |
Also... you didnt use the variable you defined which is a waste of code I would use
1 | SlvrEnable = game.ReplicatedStorage.SlvrEnable |