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

How to save a bought gear from GUI shop after death?

Asked by 3 years ago
Edited 3 years ago

Hello again! I’ve created a GUI shop with gears that player can buy with money (not R$). But if a player who bought the gear dies, he will lose it. I don’t want to make player work for money again and again. The script after buy button is pressed is

game.ReplicatedStorage.ToolEvents.DroneEvent.OnServerEvent:Connect(function(player)
    if player.leaderstats.Money.Value >= 500 then
        player.leaderstats.Money.Value = player.leaderstats.Money.Value - 500
        game.ServerStorage.Tools.SpyDrone:Clone().Parent = player.Backpack
    end
end)

I was creating tool events to make their function stay. As you see after the tool is bought its cloned to player's backpack. I'm a big rookie in scripting, so I hope you will help. Also, thanks!

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You would want to also clone another spydrone to the player's StarterGear which would give the player the spydrone after death

Now, this does not solve your question IF you want it to save when the player leaves the game

game.ReplicatedStorage.ToolEvents.DroneEvent.OnServerEvent:Connect(function(player)
    if player.leaderstats.Money.Value >= 500 then
        player.leaderstats.Money.Value = player.leaderstats.Money.Value - 500
        game.ServerStorage.Tools.SpyDrone:Clone().Parent = player.Backpack
    game.ServerStorage.Tools.SpyDrone:Clone().Parent = player.StarterGear
    end
end)
0
Tysm! This answer is the one I was dreaming about! nikitos54327 70 — 3y
Ad
Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago

Create a Boolvalue named after every gear and parent it to a Folder in every Player that joins and when the gear is bought the BoolValue is set to true and if the Player dies then the server will check if the BoolValue is true. (Keep in mind scriptinghelpers.org is NOT a request site, that is one of the reasons I didn't provide code)

0
Can you tell me how to make boolvalue in my case, please? And what do I need to do to make my question not a request? Ty nikitos54327 70 — 3y
0
Do Instance.new("BoolValue") SpectacularPavlos 86 — 3y

Answer this question