So yeah, this is all in a local script and it usually works fine in studio but not the real game.

The printing and the stuff that affects the GUI works, but nothing is ever cloned into StarterGear even though the printing says that it is.

local player = game.Players.LocalPlayer
print(player.Name)
local leaderboard = player:WaitForChild("leaderstats")
local button = script.Parent
local price = button:WaitForChild("Price")
local item = button:WaitForChild("ItemName")
local rs = game.Lighting.Lobby.Items
	
button.MouseButton1Click:Connect(function()
	print("clicked")
	if leaderboard.Points.Value>=price.Value and player.StarterGear:FindFirstChild(item.Value)==nil then
		print("bought")
		leaderboard.Points.Value = leaderboard.Points.Value-price.Value
		local iitem = rs:WaitForChild(item.Value)
		print(iitem)
		local itemc = iitem:Clone()
		itemc:Clone().Parent = player.PlayerGui.InvGui.Stuff
		itemc.Parent = player.StarterGear
		print(itemc.Parent)
		button.Text = "BOUGHT"
	elseif player.StarterGear:FindFirstChild(item.Value)~=nil then
		button.Text = "BOUGHT"
	end
end)

while wait(1)do
	button.Text = item.Value.." - "..price.Value.." pts"
end

1 comment

0

The reason why it does not work in the game because your game might have filtering enabled set to true. It works in Studio because it is set to false in studio so that you can prototype games.