I have a shop gui where you can buy weapons and gears and im trying to make it so that when a player has enough currency called Gems, they can purchase a weapon and it would go inside the player's Backpack and StarterGear. The problem that i am having is that after the weapon goes inside the player's Backpack and StarterGear and then i reset or leave the game, the weapon doesn't stay in my inventory. I have gear dev products in my game and those save in my inventory when i purchase them.
It could be that when i purchase the weapon, it's in a Local Script and i have Filtering Enabled on. But if it is, that's the problem i am having and i'm not that great with Remote Events/Functions.
This is the code in a Local Script, inside StarterGui
local player = game.Players.LocalPlayer
local gems = player:WaitForChild('leaderstats').Gems
local buyButton = script.Parent
local equipButton = script.Parent.Equip
local errorMessage = script.Parent.Parent.Parent.Parent.Parent.ErrorMessage
local gemImage = script.Parent.Gem
script.Parent.MouseButton1Click:connect(function()
if gems.Value >= 50 and not player.Backpack:FindFirstChild('HyperlaserGun') and not player.StarterGear:FindFirstChild('HyperlaserGun') and not player.Character:FindFirstChild('HyperlaserGun') then
game.Lighting.WeaponFolder.HyperlaserGun:Clone().Parent = player.Backpack
game.Lighting.WeaponFolder.HyperlaserGun:Clone().Parent = player.StarterGear
gems.Value = gems.Value - 50
equipButton.Visible = true
gemImage.Visible = false
else
if player.Backpack:FindFirstChild('HyperlaserGun') or player.StarterGear:FindFirstChild('HyperlaserGun') or player.Character:FindFirstChild('HyperlaserGun') then
errorMessage.Visible = true
errorMessage.Text = 'You already own this item!'
wait(1.5)
errorMessage.Visible = false
errorMessage.Text = "You don't have enough Gems to purchase this!"
else
errorMessage.Visible = true
wait(1.5)
errorMessage.Visible = false
end
end
end)

1 comment
I already figured out how to make this FE compatable, but that works too!