Equip button adds both my scripts

which line would i put that under tho

Something like this that should give you enough information.

1 Like

thx ok doing right now this wont take but a second

It printed

Giver Gear RainbowMagicCarpet
Giver Gear Cresencdo the soul stealer

But i could sworn i made it where a remote couldnt fire both

nvm found the problem. It seems that you donā€™t really under stand this quit well yet.

what did i do wrong because i have no idea what i did wrong?

wait didnt i already say that the equip button was the promblem

Hmm do I explain this because this is quite difficult for new learners even.
The problem is that your using 2 spsss.MouseButton1Click:Connect(function() meaning that when you press the button the you send 2 information to the server.

is there anyway i could split this that way it only sends one and not both?

Yeah you did just hate reading bunch of lines.

Hmm Iā€™ll give an example of what I did in the past.
But this is quit a big line so I donā€™t know if you would understand it, donā€™t worry Iā€™ll still explain some of the lines.

local userInput = game:GetService('UserInputService')

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local replicatedStorage = game:GetService('ReplicatedStorage')
local storageFrame = replicatedStorage:WaitForChild('Frames')

--Remote Events
local remoteFunctionsFolder = replicatedStorage:WaitForChild('RemoteFunctions')
local equipFunction = remoteFunctionsFolder:WaitForChild('EquipFunction')

--Leaderstats Variables
local leaderstats = player:WaitForChild('leaderstats')
local money = leaderstats:WaitForChild('$')
local rank = leaderstats:WaitForChild('Rank')

--Inventory Variables
local inventory = player:WaitForChild('Inventory')
local weapons = inventory:WaitForChild('Weapons')
local CurrentWeapon = inventory:WaitForChild('Current Weapon')

--Mian Frame Variables
local gui = player:WaitForChild('PlayerGui'):WaitForChild('ProfileGui')
local mainFrame = gui:WaitForChild('MainFrame')
local rightFrame = mainFrame:WaitForChild('RightFrame')
local statsFrame = rightFrame:WaitForChild('Stats')
local profileFrame = mainFrame:WaitForChild('Profile')
local mainWeaponFrame = rightFrame:WaitForChild('Weapon')

--XP Frame Variables
local xpFrame = statsFrame:WaitForChild('XP')
local xpBarFrame = xpFrame:WaitForChild('Bar')
local xpPercentageFrame = xpBarFrame:WaitForChild('Frame')
local xpPercentageLabel = xpPercentageFrame:WaitForChild('Percentage')

--Rank Frame Variables
local rankFrame = statsFrame:WaitForChild('Rank')
local rankLabel = rankFrame:WaitForChild('Label')

--Money Frame Variables
local moneyFrame = statsFrame:WaitForChild('$')
local moneyLabel = moneyFrame:WaitForChild('Label')

--Profile Frame Variables
local profileImage = profileFrame:WaitForChild('Profile')
local currentWeaponImage = profileFrame:WaitForChild('CurrentWeapon')

--Weapon Frame Variables
local weaponScrollingFrame = mainWeaponFrame:WaitForChild('ScrollingFrame')
local weaponList = weaponScrollingFrame:WaitForChild('List')
local weaponFrame = storageFrame:WaitForChild('Weapon')
local weaponStatFrame = mainFrame:WaitForChild('WeaponStats')
local weaponNameLabel = weaponStatFrame:WaitForChild('WeaponName')
local weaponDamageLabel = weaponStatFrame:WaitForChild('DamageLabel')
local weaponImage = weaponStatFrame:WaitForChild('Weapon')
local EquipButton = weaponStatFrame:WaitForChild('EquipButton')
local weaponsFolder = replicatedStorage:WaitForChild('Weapons')

--Other Player Frame Variables
local otherPlayerButton = profileFrame:WaitForChild('OtherPlayerFrame'):WaitForChild('OtherPlayerButton')
local otherPlayerMainFrame = rightFrame:WaitForChild('OtherPlayers')
local otherPlayerScrollingFrame = otherPlayerMainFrame:WaitForChild('ScrollingFrame')
local otherPlayerList = otherPlayerScrollingFrame:WaitForChild('List')
local otherPlayerFrame = storageFrame:WaitForChild('Player')

repeat wait(1) until weaponsFolder:FindFirstChild(CurrentWeapon.Value) ~= nil
currentWeaponImage.Image = weaponsFolder:FindFirstChild(CurrentWeapon.Value).TextureId

--Update Rank
rankLabel.Text = 'Rank: '..rank.Value

rank.Changed:Connect(function()
	rankLabel.Text = 'Rank: '..rank.Value
end)

--Update Money
moneyLabel.Text = "$: "..money.Value

money.Changed:Connect(function()
	moneyLabel.Text = "$: "..money.Value
end)

--Update XP
xpFrame.MouseEnter:Connect(function()
	xpPercentageFrame.Visible = true
end)

xpFrame.MouseLeave:Connect(function()
	xpPercentageFrame.Visible = false
end)

xpPercentageLabel.Text = math.floor(xpBarFrame.Size.X.Scale * 100).."%"

xpBarFrame.Changed:Connect(function(value)
	if value == 'Size' then
		xpPercentageLabel.Text = math.floor(xpBarFrame.Size.X.Scale * 100).."%"
	end
end)

--Fetch the thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)

profileImage.Image = content

--Update Weapon Inventory
currentWeaponImage.MouseButton1Click:Connect(function()
	if weaponsFolder:FindFirstChild(CurrentWeapon.Value) ~= nil then
		local name = CurrentWeapon.Value
		local theWeapon = weaponsFolder:FindFirstChild(CurrentWeapon.Value)
		local weaponDamage = theWeapon:GetAttribute('Damage')
		
		if weaponStatFrame.Visible == true and weaponNameLabel.Text == name then
			weaponStatFrame.Visible = false
		elseif weaponStatFrame.Visible == false then
			weaponStatFrame.Visible = true
		end

		if weaponNameLabel.Text ~= name then
			weaponNameLabel.Text = name
			weaponDamageLabel.Text = 'DMG: '..weaponDamage
			weaponImage.Image = theWeapon.TextureId

			if CurrentWeapon.Value ~= name then
				EquipButton.Text = 'Equip'
			else
				EquipButton.Text ='Equipped'
			end
		end
	end
end)

EquipButton.MouseButton1Click:Connect(function()
	if EquipButton.Text == 'Equip' then
		local equipText = equipFunction:InvokeServer(weaponNameLabel.Text)
		
		if equipText == 'Equipped' then
			if weaponsFolder:FindFirstChild(weaponNameLabel.Text) ~= nil then
				EquipButton.Text = equipText
			end
		end
	end
end)

CurrentWeapon.Changed:Connect(function()
	if gui.Enabled == true then
		currentWeaponImage.Image = weaponsFolder:FindFirstChild(CurrentWeapon.Value).TextureId
	end
end)

function updateInventory()
	for name in string.gmatch(weapons.Value, '[^,]+') do
		if weaponList:FindFirstChild(name) == nil then
			if weaponsFolder:FindFirstChild(name) ~= nil then
				local newWeaponFrame = weaponFrame:Clone()
				local weaponButton = newWeaponFrame:WaitForChild('WeaponButton')
				local theWeapon = weaponsFolder:FindFirstChild(name)
				local weaponDamage = theWeapon:GetAttribute('Damage')
				
				newWeaponFrame.Parent = weaponList
				newWeaponFrame.Name = name
				newWeaponFrame.LayoutOrder = weaponDamage
				weaponButton.Image = theWeapon.TextureId

				weaponButton.MouseButton1Click:Connect(function()
					local weapon = theWeapon
					
					if weaponStatFrame.Visible == true and weaponNameLabel.Text == weapon.Name then
						weaponStatFrame.Visible = false
					elseif weaponStatFrame.Visible == false then
						weaponStatFrame.Visible = true
					end

					if weaponNameLabel.Text ~= weapon.Name then
						weaponNameLabel.Text = weapon.Name
						weaponDamageLabel.Text = 'DMG: '..weapon:GetAttribute("Damage")
						weaponImage.Image = weapon.TextureId

						if CurrentWeapon.Value ~= weapon.Name then
							EquipButton.Text = 'Equip'
						else
							EquipButton.Text ='Equipped'
						end
					end
				end)
			end
		end
	end
	
	for i, frame in pairs(weaponList:GetChildren()) do
		if string.find(weapons.Value, frame.Name) == nil and not frame:IsA('UIGridLayout') then
			frame:Destroy()
		end
	end

end

weapons.Changed:Connect(function()
	updateInventory()
end)

--Update Other Player Stats
function otherPlayerRankOrder(playerRank)
	local rankList = {
		'SSS+',
		'SSS-III',
		'SSS-II',
		'SSS-I',
		'SS+',
		'SS-III',
		'SS-II',
		'SS-I',
		'S+',
		'S-III',
		'S-II',
		'S-I',
		'A+',
		'A-III',
		'A-II',
		'A-I',
		'B-III',
		'B-II',
		'B-I',
		'C-III',
		'C-II',
		'C-I',
		'D-III',
		'D-II',
		'D-I',
		'E-III',
		'E-II',
		'E-I',
		'F-III',
		'F-II',
		'F-I',
	}
	
	for i, rank in pairs(rankList) do
		if rank == playerRank then
			return i
		end
	end
end

otherPlayerButton.MouseButton1Click:Connect(function()
	if otherPlayerMainFrame.Visible == true then
		otherPlayerMainFrame.Visible = false
	else
		otherPlayerMainFrame.Visible = true
	end
end)

function updateOtherPlayerStats()
	for i, otherPlayer in pairs(game:GetService('Players'):GetPlayers()) do
		if otherPlayer.UserId ~= player.UserId and otherPlayerList:FindFirstChild(otherPlayer.UserId) == nil then
			spawn(function()
				local otherPlayerContent, isReady = Players:GetUserThumbnailAsync(otherPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
				local otherPlayerRank = otherPlayer:WaitForChild('leaderstats'):WaitForChild('Rank')
				local otherPlayerCurrentWeapon = otherPlayer:WaitForChild('Inventory'):WaitForChild('Current Weapon')
				local newOtherPlayerFrame = otherPlayerFrame:Clone()
				local rankLayout = otherPlayerRankOrder(otherPlayerRank.Value)

				newOtherPlayerFrame.Name = otherPlayer.UserId
				newOtherPlayerFrame.LayoutOrder = rankLayout

				newOtherPlayerFrame.Frame.CurrentWeaponLabel.Text = otherPlayerCurrentWeapon.Value
				newOtherPlayerFrame.Frame.RankLabel.Text = 'Rank: '..otherPlayerRank.Value

				newOtherPlayerFrame.Frame.PlayerProfile.Image = otherPlayerContent
				newOtherPlayerFrame.Frame.PlayerProfile.PlayerName:FindFirstChild('Name').Text = otherPlayer.Name

				newOtherPlayerFrame.Frame.PlayerProfile.MouseEnter:Connect(function()
					newOtherPlayerFrame.Frame.PlayerProfile:WaitForChild('PlayerName').Visible = true
				end)

				newOtherPlayerFrame.Frame.PlayerProfile.MouseLeave:Connect(function()
					newOtherPlayerFrame.Frame.PlayerProfile:WaitForChild('PlayerName').Visible = false
				end)
				
				otherPlayerCurrentWeapon.Changed:Connect(function()
					newOtherPlayerFrame.Frame.CurrentWeaponLabel.Text = otherPlayerCurrentWeapon.Value
				end)
				
				otherPlayerRank.Changed:Connect(function()
					newOtherPlayerFrame.Frame.RankLabel.Text = 'Rank: '..otherPlayerRank.Value
				end)
				
				if otherPlayerList:FindFirstChild(newOtherPlayerFrame.Name) ~= nil then
					newOtherPlayerFrame:Destroy()
				else
					newOtherPlayerFrame.Parent = otherPlayerList
				end
			end)
		end
	end
end

Players.PlayerAdded:Connect(function(otherPlayer)
	updateOtherPlayerStats()
end)

Players.PlayerRemoving:Connect(function(player)
	if player ~= Players.LocalPlayer then
		otherPlayerList:FindFirstChild(player.UserId):Destroy()
	end
	
end)

updateOtherPlayerStats()
updateInventory()

can you delete the parts where its not rlly weapons?

Wait give me a sect Iā€™ll just find quote it let me just find it.

Found it:

EquipButton.MouseButton1Click:Connect(function()
	if EquipButton.Text == 'Equip' then
		local equipText = equipFunction:InvokeServer(weaponNameLabel.Text)
		
		if equipText == 'Equipped' then
			if weaponsFolder:FindFirstChild(weaponNameLabel.Text) ~= nil then
				EquipButton.Text = equipText
			end
		end
	end
end)

This is the line where I send the information to the server you donā€™t really need to use remote function; I just used it because I want the information once the character have equipped the tool.

So what you could do is check first what the player chose(The weapon), so once the player chose the weapon, you could have a StringValue (This is a Instance), to save what the player chose and once the player pressed the equip/unequip you can send the information to the server. Or what I did is use the information from the weaponNameLabel.Text the text.

this doesnt rlly look difficult

wdym by to save what the player chose im not gonna make a save option for my game, that would be a feature when i get better at coding

Thatā€™s not what I meant. Like just save what the player chose, to be able to use the equip/unequipped button.

is this a gate for instance the gate would act the same as the remote event where it doesnt add both but one correct?

Yes something like that, where you only use one button to send the information to the server