So, it works and only 1 tool can be equipped at a time but the first 2 tools i buy and equip they both say equipped when only 1 is. How do I get only 1 to say equipped?

Script:

local modelName = script.Parent.Parent.ModelName
local boxName = script.Parent.Parent.Parent.CurrentBox

script.Parent.MouseButton1Click:Connect(function()

	local outcome = game.ReplicatedStorage.CreateTransaction:InvokeServer(modelName.Value)

	if outcome == true then
		
		
		
		script.Parent.Text = "Equipped"
	
	elseif outcome == "not enough cash" then
		
	elseif outcome == "already bought" then
		if game.Players.LocalPlayer.Equipped.Value ~= modelName.Value then
			game.ReplicatedStorage.EquipTool:FireServer(modelName.Value)
			script.Parent.Text = "Equipped"
		end
	end

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

	
	
end)

5 comments

0

Um, only one Tool can be equipped at a time regardless of a Script.

0

No its an equip button the text on the button says equip and equipped when equipped but when you equip 2 tools after, the one before is suppose to go back to "equip" but it stays at "equipped"

0

Ah, then store the Currently Equipped box as a variable, then the next time something is equipped, set that box to Unequipped, the reset the variable to the new Equipped box.

0

Im sort of new to scripting so i kind of got what your saying but exactly what do you mean?? Dont make fun of me..

0

hmm?