Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Buy button for shop won't update correctly, how do I fix??

So, in my game, I have a shop. The buy button is supposed to update to "Equip," "Equipped," etc, but it doesn't work right. Even if the player's equipped value is a certain skin, it won't say equipped! Client - side script:

boxName:GetPropertyChangedSignal("Value"):Connect(function()
	
	local model = nil
	
	for i, object in pairs(game.Workspace.Shop.ItemRoller["Box"..boxName.Value]:GetChildren()) do
		if object:IsA("Model") then
			model = object
		end
	end
	
	local toolsBought = game.ReplicatedStorage.GetSkinsBought:InvokeServer()
	
	for i, tool in pairs(toolsBought) do
		if tool == model.Name then
			script.Parent.Text = "Equipped"
		else
			script.Parent.Text = "Equip"
		end
	end
	
	print(script.Parent.Text)
	
end)

(The parent is the button.)

Server - side:

game.ReplicatedStorage.GetSkinsBought.OnServerInvoke = function(player)
	
	local tools = {}
	
	for i, tool in pairs(game.ServerStorage.PlayerSkins[player.Name]:GetChildren()) do
		table.insert(tools,tool.Name)
		print(tool)
	end
	
	return tools
	
end

HELP

1 answer

In your assignment to model, you try to get "model.Name", but that doesn't exist outside of the for loop (Since your trying to explicitly get the object..which you have no reference to), thus it actually turning out to be nil. Since your trying to grab the name anyways, just store within model "object.Name". That should do it. If not, please comment.

Hope This Helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.