:InvokeServer() more than one time in a script

How to invoke server multiple times in a script

primarySelectedItem:GetPropertyChangedSignal("Value"):Connect(function()
	wait(.1)
	*local result = game.ReplicatedStorage.PurchaseItem:InvokeServer(primarySelectedItem.Value)*
	if result == true then
		primaryBuyButton.Text = "Equip"
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
	elseif result == "NotEnoughBucks" then
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(204, 31, 31)
		primaryBuyButton.Text = "Not Enough bucks!"
		primarySelectedItem.Value = primarySelectedItem.Value
		wait(.3)
		primaryBuyButton.Text = "Buy"
		primarySelectedItem.Value = primarySelectedItem.Value
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
	elseif result == "Equipped" then
		primaryEquippedItem.Value = primarySelectedItem.Value
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(42, 149, 42)
		primaryBuyButton.Text = "Equipped"
	end
end)

primaryBuyButton.MouseButton1Click:Connect(function()
	wait(.1)
	*local result = game.ReplicatedStorage.PurchaseItem:InvokeServer(primarySelectedItem.Value)*
	if result == true then
		primaryBuyButton.Text = "Equip"
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
	elseif result == "NotEnoughBucks" then
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(204, 31, 31)
		primaryBuyButton.Text = "Not Enough bucks!"
		primarySelectedItem.Value = primarySelectedItem.Value
		wait(.3)
		primaryBuyButton.Text = "Buy"
		primarySelectedItem.Value = primarySelectedItem.Value
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
	elseif result == "Equipped" then
		primaryEquippedItem.Value = primarySelectedItem.Value
		primaryBuyButton.BackgroundColor3 = Color3.fromRGB(42, 149, 42)
		primaryBuyButton.Text = "Equipped"
	end
end)

The question is rather blunt. Can you elaborate what exactly by the means of “more than one time” and the expected result?

ma bad I already find the answer
but thanks for coming to help me

how can I delete this Topic :smiley:

You don’t have to, just provide the answer here and you’ll help others for future references.

1 Like