This GUI shop script works fine, other than the fact that when the gun is placed in your backpack, it's broken, with some parts no appearing, and it glitching your character's movement. However, upon resetting and equipping the tool again, the gun is fine.
And using admin commands to give a player a gun will not break it either, as the gun will be perfectly fine upon loading.
I have no idea why this is happening. Is there anyway to fix this issue without needing an external script?
Here's the script:
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats.Cash.Value >= tonumber(script.Parent.Cost.Value) then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value-tonumber(script.Parent.Cost.Value)
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.Backpack
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.StarterGear
wait(0.1)
script:Destroy()
end
end
end)
while wait(0.1) do
script.Parent.Text=tostring(script.Parent.ItemName.Value)..": $"..tonumber(script.Parent.Cost.Value)..""
end

7 comments
You'll most likely have to refresh all the weapon's scripts after adding them to the backpack by using the .Disabled property. Try it, it may work.
Ew, Lighting.
I'm only using Lighting because of the admin commands in the game, that I'd rather not mess with.
@Wutras I tried hat method, it still didn't work.
Have you tried :MakeJoints()? Might work, not sure.
@ISellCows I tried that as well. Didn't work. It might be because of the unions.
lol