There are 3 different types of gears; Melee, Ranged, and Special. Each gear has a StringValue
which value has either Melee
, Ranged
, or Special
. When they go to purchase an item in the shop, I want the gear in the player's Backpack
or Character
(if they're holding it) to be replaced with the new gear that they purchased. Here's the script:
local player = game.Players.LocalPlayer local cash = player:WaitForChild('leaderstats').Cash local amount = 400 local weapons = game.ReplicatedStorage.Weapons local tool = weapons.GravityDisruptor local indexText = script.Parent.Text script.Parent.MouseButton1Click:connect(function() if cash.Value >= amount and not player.Backpack:FindFirstChild('GravityDisruptor') or player.Character:FindFirstChild('GravityDisruptor')then --They don't have it local newTool = tool:Clone() local newTool2 = tool:Clone() newTool2.Parent = player.Backpack newTool.Parent = player.StarterGear else script.Parent.Text = "Purchased Failed!" wait(3) script.Parent.Text = indexText end end) script.Parent.MouseEnter:connect(function() script.Parent.Parent.Parent.Parent.ProductImage.Image = "rbxassetid://"..script.ImageValue.Value script.Parent.Parent.Parent.Parent.Description.Text = script.Description.Value script.Parent.Parent.Parent.Parent.ProductTitle.Text = script.Title.Value end) script.Parent.MouseLeave:connect(function() script.Parent.Parent.Parent.Parent.ProductImage.Image = "rbxassetid://" script.Parent.Parent.Parent.Parent.Description.Text = "" script.Parent.Parent.Parent.Parent.ProductTitle.Text = "" end)