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
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?
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