Shop GUI not working still

My shop gui still won’t work I got help and everything worked but the tool

The tool will not go in my inventory

I did this website and google and developer hub

I did everything I could I can’t figure it out

-- LocalScript
local Tools = game.ReplicatedStorage:WaitForChild("Tools")
local player = game:GetService("Players").LocalPlayer

local remoteEvent = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("BuyItemEvent")

local function buyItem()
	remoteEvent:FireServer("Laser Gun")
	script.Parent.Bought.BackgroundColor3 = Color3.fromRGB(0,255,0)
end

script.Parent.MouseButton1Click:Connect(buyItem)

-- ServerScript
local Tools = game.ReplicatedStorage:WaitForChild("Tools")
local LaserGun = Tools:WaitForChild("Laser Gun")

game.ReplicatedStorage.Events.BuyItemEvent.OnServerEvent:Connect(function(player, tool)
	if tool == "Laser Gun" then
		if player.leaderstats.Cash.Value >= 350 then
			local itemClone = LaserGun:Clone()
			itemClone.Parent = player:WaitForChild("Backpack")
			player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 350
			return nil
		end
	end
end)
1 Like

Critisism is fine I would recommend it

2 things, why check for just laser gun? That would take more if statements, try all at once. 2. Wouldn’t you want it to go to backpack AND startergear?

itemClone.Parent = player:WaitForChild(“Backpack”)

itemClone.Parent = player.Backpack

Does the tool have an handle? Make sure it is a tool and has a handle

Yes it does I have one I just checked

Is the so called Lasergun a tool? make sure it’s a tool, and also are there any errors? we need as much information as we can get to help you

No just backpack starter gear is when someone just joined

But when they die they would lose it correct? Do you want that?

No there is no errors it just does not give me the tool or even clone for the fact

Try what @YourBossyLord said for starters.

2 Likes

No I do not want that ( need characters )

I will send screenshots ( EEEEE )

Trust me, I had these issues, it’s because if you wait for the players Backpack, it won’t work… Use a script to ; tool.Parent = player.Backpack

image

Ok I will try right now :slight_smile:

Could you possibly send the file containing all of the shop descendants? I tried to re-make it, and it worked fine for me.

I do not know how I am kinda new to studio

Did not work I do not know why

Group the GUI, tools folder, scripts together and export it as an rbxm file.

1 Like