remoteEvent not firing on client

i was trying make a script for my class-based combat game and i tried make a local script place certains UI on the player if they are from a certain class, but the local script isnt firing, the detector server-sided script works but the local script doesnt, the only thing i have tried currently was change the remoteEvent location

the faulty code:

local selector = script.Parent
local event = game.ReplicatedStorage:WaitForChild("insert ui")

local classFolder = game.ReplicatedFirst:WaitForChild("classes")

event.OnClientEvent:Connect(function(class)
	local chosenClass = classFolder:FindFirstChild(class)
	local ui = chosenClass:FindFirstChild("UI")
	
	for i,v in pairs(ui:GetChildren()) do
		if v:IsA("LocalScript") then
			local clone = v:Clone()
			clone.Enabled = true
			clone.Parent = game.Players.LocalPlayer.PlayerGui
			print("UI INSERTED")
			print(clone.Name..", "..clone.Parent.Name)
		end
	end
end)

the server script that should trigger it (it prints “UI FOUND” succesfully)

if chosenClass:FindFirstChild("UI") then
			print("UI FOUND")
			uiInserter:FireClient(plr, class)
		end

In Server Script add wait(3) in the very beginning of the code

Can you clarify your problem a bit further? I don’t understand what you mean by "the detector server-sided script works but the local script doesnt" Is the remote event not being received on the client?

Instead of making the server send the client a request, you should make the client use a RemoteFunction because they can return values.

the server sided script is the one that finds if the folder have an UI, and triggers a event if it have, but the local script isnt triggering a function when it happens

Well if you want the server to insert the ScreenGui, there’s no need to send it to the client. The server can simply clone the GUI and put it in Player.PlayerGui

the UI i trying send is a localScript, to give the UI a 3d-ish effect

Yeah but you can still send the LocalScript through the GUI if the Server puts it in PlayerGui

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.