--Script:
local Device = game:GetService("ReplicatedStorage").RemoteEvent:FireClient(player, what)
wait()
print(Device) -- prints only nil
--LocalScript:
game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function(what)
if what == "1" then
return "Character"
elseif what == "2" then
return "Player"
end
return "HAYHAY"
end)
The code on the variable is firing, not really declaring. You should try to check if the remote event actually exists in place first on client.
You can either use two or the same remote event where the client fires it and allowing the server to use OnServerEvent as an option, or simply the below.
You can use a yielding time limit. If the timer runs out, you can just use return nil. This will prevent exploiters from blocking out the server forever.