local box = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character
local rS = game:GetService("ReplicatedStorage")
local event = rS.Events.ClassChange
function change()
local class = rS.Classes:FindFirstChild(string.lower(box.Text))
if class then
event:FireServer(class)
task.wait(1)
end
end
function changeCam(char)
workspace.CurrentCamera.CameraSubject = char.Humanoid
print("a")
end
event.OnClientEvent:Connect(changeCam)
box.FocusLost:Connect(change)
If you’re only playtesting this in studio, your Server scripts might not be initializing before your Client scripts are. Try adding a wait before you call exaFunc for the first time.
Hm. It’s likely we’d need to see your actual codebase (if not at least a detailed skeleton of its operation until the issue occurs) to assist with this.
Because otherwise, your code should work fine.
local box = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character
local rS = game:GetService("ReplicatedStorage")
local event = rS.Events.ClassChange
function change()
local class = rS.Classes:FindFirstChild(string.lower(box.Text))
if class then
event:FireServer(class)
task.wait(1)
end
end
function changeCam(char)
workspace.CurrentCamera.CameraSubject = char.Humanoid
print("a")
end
event.OnClientEvent:Connect(changeCam)
box.FocusLost:Connect(change)
Could you check if it’s firing the server? Or the OnServerEvent function is playing? Before that your checking if the class exists and if it doesn’t it wont go through.