RemoteEvent Only firing once

  1. What do you want to achieve? Keep it simple and clear!

I’m making a Class Selection System.

  1. What is the issue? Include screenshots / videos if possible!

So the script works fine the first time, so for example you select Mage Class and it gives you the tools, and if you press Remove Class it removes the tools, but if you wanna select Mage Class again it doesn’t work. The Issue is that the RemoteEvent is only firing once and I don’t know how to fix that,

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried looking in the devoforum, and none of the posts helped.

Note: I know it’s an issue from the RemoteEvent because the script prints when you click the button, but the second time it doesn’t print when the player gets the tools (which happens after the event is fired).

Here are my Scritps:

First one (Localscript, inside the GUI):


-- // VARIABLES

local ScreenGui = script.Parent.Parent

local Frame = ScreenGui.Frame

local Button1 = Frame.Button1 -- Mage Class
local Button2 = Frame.Button2 -- Warrior Class
local Button3 = Frame.Button3 -- Lord Class
local Button4 = Frame.Button4 -- Defender Class
local Button5 = Frame.Button5 -- Pog Class
local Button6 = Frame.Button6 -- Remove Class

local Value = ScreenGui.PlayerChoseClass
Value.Value = false

local imagelabelsfolder = Frame.Images


local players = game.Players
local player = game.Players.LocalPlayer

-- // SERVICES

local userinputservice = game:GetService("UserInputService")
local runservice = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local EventsFolder = ReplicatedStorage:WaitForChild("Classes")

local PogEvent = EventsFolder.Pog
local DefenderEvent = EventsFolder.Defender
local LordEvent = EventsFolder.Lord
local WarriorEvent = EventsFolder.Warrior
local MageEvent = EventsFolder.Mage
local RemoveEvent = EventsFolder.RemoveClass

-- // MAIN SCRIPT // FUNCTIONS


local function MageClass()
	if Value.Value == false then
		MageEvent:FireServer(player)
		Value.Value = true
		print("Mage Selected")
	end
end

local function DefenderClass()
	if Value.Value == false then
		DefenderEvent:FireServer(player)
		Value.Value = true
	end
end

local function LordClass()
	if Value.Value == false then
		LordEvent:FireServer(player)
		Value.Value = true
	end
end

local function WarriorClass()
	if Value.Value == false then
		WarriorEvent:FireServer(player)
		Value.Value = true
	elseif Value.Value == true then
		print("You already have a Class selected!")
	end
end

local function PogClass()
	if Value.Value == false then
		PogEvent:FireServer(player)
		Value.Value = true
	end
end

local function RemoveClass()
	if Value.Value == true then
		RemoveEvent:FireServer(player)
		Value.Value = false
	end
end


-- // MAIN SCRIPT // BINDING SCRIPTS

Button1.MouseButton1Click:Connect(MageClass)
Button2.MouseButton1Click:Connect(WarriorClass)
Button3.MouseButton1Click:Connect(LordClass)
Button4.MouseButton1Click:Connect(DefenderClass)
Button5.MouseButton1Click:Connect(PogClass)
Button6.MouseButton1Click:Connect(RemoveClass)

Second Script in ServerScriptService:





-- // VARIABLES

local serverstorage = game.ServerStorage
local folder = serverstorage.Classes

local WarriorFolder = folder.Warrior
local MageFolder = folder.Mage


local EventsFolder = game:GetService("ReplicatedStorage").Classes

local PogEvent = EventsFolder.Pog
local DefenderEvent = EventsFolder.Defender
local LordEvent = EventsFolder.Lord
local WarriorEvent = EventsFolder.Warrior
local MageEvent = EventsFolder.Mage

local function MageClass(player)
	for i,v in pairs(MageFolder:GetChildren()) do
		v.Parent = player.Backpack
		print("Mage Tools Given")
	end
end

local function DefenderClass(player)
	
end

local function LordClass(player)
	
end

local function WarriorClass(player)
	for i,v in pairs(WarriorFolder:GetChildren()) do
		v.Parent = player.Backpack
	end
end

local function PogClass(player)
	
end

local function Remove(player)
	for i,v in pairs(player.Backpack:GetChildren()) do
		if v:IsA("Tool") then
			local Attirbute = v:GetAttribute("IsClassItem")
			if Attirbute then
				v:Destroy()
			end
		end
	end
end

MageEvent.OnServerEvent:Connect(MageClass)
WarriorEvent.OnServerEvent:Connect(WarriorClass)
EventsFolder.RemoveClass.OnServerEvent:Connect(Remove)

ANOTHER NOTE: YES, THE SECOND SCRIPT ISN’T FINISHED, THATS BECAUSE I ONLY SCRIPTED THE MAGE CLASS AND THE WARRIOR CLASS.

You need to clone the tool otherwise you’re just using the same tools and once they get moved once they won’t be moved again.

local function MageClass(player)
	for i,v in pairs(MageFolder:GetChildren()) do
		v:Clone().Parent = player.Backpack
		print("Mage Tools Given")
	end
end

Wow I forgor to clone the tools. Thank you so much, it works now! :grinning: